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.
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);
本文探讨了在使用较新版本的Java编译器时遇到的关于List泛型警告的问题,并提供了几种解决方法,包括使用泛型类型、未知类型的通配符以及通过注解来抑制警告。
1万+

被折叠的 条评论
为什么被折叠?



