当我将 String 对象添加到 vector 中时,会出现以下警告。为什么?
TestCollectionsMain.java:14: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector vec.add("M");
最佳答案
这是因为您没有使用泛型来声明您的 Vector。
试试这个:
List<String> vec = new ArrayList<String>();
vec.add("M");
关于java vector : Warning while adding objects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3089871/