日期:2014-05-20 浏览次数:20672 次
public class Holder3 <T>{
private T a;
public Holder3(T a){
this.a = a;
System.out.println(a);
}
public void set(T a){
this.a = a;
}
public T get(){
return a;
}
public static void main(String[] args){
Holder3<Tetris> h3 = new Holder3(new hello());//该行无报错
// Tetris a = h3.get();//抛出异常
}
}
Holder3<Tetris> h3 = new Holder3(new hello());//该行无报错
// Tetris a = h3.get();//抛出异常
Holder3<Tetris> h3 = new Holder3<Tetris>(new Tetris());//该行无报错
// Tetris a = h3.get();//抛出异常