泛型的产生
代码段:
public class FanXing {
public static void main(String[] args) {
// TODO Auto-generated method stub
Bird<String> bird=new Bird<String>("marry");
System.out.println(bird.getTypeName());
}
}
class Bird<T>{
private T name;
public Bird(T birdName){
name=birdName;
}
public T getName() {
return name;
}
public void setName(T name) {
this.name = name;
}
public String getTypeName(){
return name.getClass().getName();
//反射机制
}
}