泛型

package orz.zxj.fx;

class Test<T1,T2>{
 private T1 name;
 private T2 age;
 public void setName(T1 name){
  this.name = name;
 }
 public void setAge(T2 age){
  this.age = age;
 }
 public T1 getName(){
  return this.name;
 }
 public T2 getAge(){
  return this.age;
 }
 public void printOut(){
  System.out.println("Name:"+this.name + "    Age:"+this.age);
 }
}
public class fanxing{
 public static void main(String[] args){
  Test<String ,Integer> T = new Test<String ,Integer>();
  T.setName("aaaaaaa");
  T.setAge(555);
  T.printOut();
 }
}

posted @ 2011-05-24 11:25  sirzxj  阅读(126)  评论(0编辑  收藏  举报