import java.util.*;
class Generc_Text {
public static void main(String[] args){
Utils<Person> u = new Utils<Person>();
Person p =new Person("张三",23);
u.println(p);
}
}
class Utils<T>{
public void println(T t){
System.out.println(t.getName());
}
public <Y> void show(Y y){
System.out.println(y);
}
}
class Person {
private String name;
private int age;
Person(String name,int age){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
} |
|