Syntax error, parameterized types are only available if source level is 5.0

List<User> users = new ArrayList<User>();

在左边出现一个小红叉,报错:

"Syntax error,parameterized types are only available if source level is 5.0"

说明编译环境不是在5.0,但是MyEclipse中应用的jdk明明是1.5或以上版本。

有两种方法处理:

一种是Myeclipse对所有项目默认的设置是5.0以下,项目继承了默认设置(在Myeclipse IDE中的菜单Window/Preferences/Java/Compiler里改为5.0或高于5.0)

另一种是单个项目里设置了source level 5.0以下(在项目属性/Java Compiler 里改为5.0或高于5.0)




在myeclipse里引入新项目的时候会报如下错误:

在使用泛型的地方提示:

Multiple markers at this line 
- Syntax error, parameterized types are only available if source level 
is 5.0 
- The type List is not generic; it cannot be parameterized with 
arguments <Application>

1)一种是Eclipse对所有项目默认的设置是5.0以下,项目继承了默认设置(在Preferences/Java/Compiler里改为5.0或高于5.0)
另一种是项目里设置了source level 5.0以下(在 项目属性/Java Compiler 里改为5.0或高于5.0)

 

你的JDK 版本比较旧,或者你装了比较新的版本,但是你在Eclipse中的设置有问题,编译级别设置的不是比较新的版本的编译器。
eclipse措无题诗如下: 
Multiple markers at this line 
- Syntax error, parameterized types are only available if source level 
is 5.0 
译:语法错误 ,泛型只有在5.0以上的版本才支持 
- The type List is not generic; it cannot be parameterized with 
arguments <Application> 
List 不是泛型,引起的原因还是编译器不支持~~ 

这时候需要改动两个地方:

1.右击项目-->properties-->java compiler -->选择enabel project specific setting -->Compiler compliance level :选择1.5版本,其他默认

2.右击项目-->properties -->project facets-->将java后的下拉框选择为5.0


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值