列表是一种原始类型。对泛型类型的引用< E>应该参数化 [英] List is a raw type. References to generic type List<E> should be parameterized
问题描述
以下是我的语法
列出synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
我收到以下语法错误:
List是一个原始类型。对泛型类型的引用< E>应该参数化。
请提出解决方案。 / div>
我相信
List是一种原始类型。引用泛型类型List应该被参数化
不是错误,而是一个警告。
如果您打算使用Java,那么了解泛型是一个基石,所以我建议您应该查看java的教程页面以了解这个:
因此,如果您知道 publiesdList
中包含的对象类型,则您可以执行此操作:
列表与LT; YourType> synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
如果列表中存在多种类型的对象,则可以使用通配符:
列表<?> synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
或者如果你只是想摆脱警告,你可以像这样压制它: p>
@SuppressWarnings(rawtypes)
List synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
但不推荐后者。
Below is my syntax
List synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
I am getting a syntax error of:
List is a raw type. References to generic type List<E> should be parameterized.
Please suggest the solution.
I believe that
List is a raw type. References to generic type List should be parameterized
is not an error, but a warning.
Understanding generics is a cornerstone if you are planning to use Java so I suggest that you should check out java's tutorial pages about this:
So if you know what type of objects are contained in publiesdList
, than you can do this:
List<YourType> synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
If there are multiple types of objects in your list than you can use a wildcard:
List<?> synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
Or if you just want to get rid of the warning than you can suppress it like this:
@SuppressWarnings("rawtypes")
List synchronizedpubliesdList = Collections.synchronizedList(publiesdList);
the latter is not recommended however.
这篇关于列表是一种原始类型。对泛型类型的引用< E>应该参数化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!