interface Info{
};
class Introduction implements Info{
String name;
String age;
String sex;
public Introduction(String name,String age,String sex){
this.name = name;
this.age = age;
this.sex = sex;
}
public String toString(){
return "个人信息:\n" +
"\t姓名:" + name +
"\t年龄:" + age +
"\t性别:" + sex;
}
};
class Person<T extends Info>{
T per;
public Person(T info){
this.per = info;
}
public String toString(){
return per.toString();
}
};
public class InfoAnd{
public static void main(String args[]){
Person<Introduction> per = null;
per = new Person<Introduction>(new Introduction("xx","30","girl"));
System.out.println(per.toString());
}
}
就是为了熟悉泛型的操作