rowdata.add(hang);
// Type safety: The method add(Object) belongs to the raw type Vector. References to generic type Vector<E> should be parameterized
// 为什么会报这个警告???
Type safety: The method add(Object) belongs to the raw type Vector. References to generic type Vector<E> should be parameterized
翻译:类型安全:该方法添加(对象)属于原始类型向量。对泛型类型向量的引用要进行参数化
分析;
这是因为JDK 1.5版本的新功能,需要对List,Vector之类定义时候,最好进行泛化。
定义类型,如:Vector<String> v = new Vector<String>();
这样的好处是再你add("abc");后想获取这个元素不需要再转化了。
如,v.get(0)将返回的就是一个String对象。
显示类型转换:
Vector <String > v=new Vector<String>();
即可,解决问题