package rawtype;
import java.util.Vector;
//类型消除的使用,它可以向它的非泛型版本的一个引用分配一个泛型引用。
//??尽管编译时不会出错但是在编译的时候会出现未检查的警告
public class raw_type {
public void processIntValue(Vector<Integer> v){
System.out.println("---");
}
public static void main(String[] args) {
Vector<Integer> intVector = new Vector<Integer>();
Vector oldVector = new Vector();
raw_type rt =new raw_type();
oldVector = intVector;
intVector = oldVector;//warning 非泛型引用赋给泛型引用,会改变泛型的参数类型,所以有警告
rt.processIntValue(intVector);
rt.processIntValue(oldVector);//warning
}
}
//消除改变方法的参数类型或原始类型的域赋值的时,如果消除改变方法/域类型就会出现这种情况。
class A{
void nerer(){Vector ov= new Vector();
Vector<Integer> iv= new Vector<Integer>();
// iv =ov;//1 warning
// ov = iv;//2no warning
}
}