欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java,

来源: javaer 分享于  点击 29541 次 点评:34

java,


As the java has evolved from the old java without generic to java with advanced generic containers. You will see the following code will be flagged as an error by the Java compiler.

 

 

List children = config_.getElements(name);

 

 you will probably see the following error when you run some recent version of compilers. Here is the error message.

 

 

 写道 List is a raw type. References to generic type List<E> should be parameterized

 There are serveral ways that you can get pass it. first and the simplest way is to use the Generic types List<T>, here is the code

 

List<YourType> synchronizedpubliesdList = Collections.synchronizedList(publiesdList);

 But this is based on the assumption that you know the type in advance, but you may not know the type in advance, you will need to do the following.

 

List<?> synchronizedpubliesdList = Collections.synchronizedList(publiesdList);

 And you can even suppress the warnings by the folowing.

 

@SuppressWarnings("rawtypes")
List synchronizedpubliesdList = Collections.synchronizedList(publiesdList);

 

So my case, I simple do the folllowing.

 

	List<?> children = config_.getElements(name);
 

 

相关文章

    暂无相关文章
相关栏目:

用户点评