P386
package com.cnsuning.src;
import java.lang.reflect.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Holder<String> holder = new Holder<String>();
holder.setH1("S1");
holder.setH2("S2");
holder.setH3("S3");
System.out.println(holder.getH1());
System.out.println(holder.getH2());
System.out.println(holder.getH3());
}
}
class Holder<T>{
private T h1;
private T h2;
private T h3;
public T getH1() {
return h1;
}
public void setH1(T h1) {
this.h1 = h1;
}
public T getH2() {
return h2;
}
public void setH2(T h2) {
this.h2 = h2;
}
public T getH3() {
return h3;
}
public void setH3(T h3) {
this.h3 = h3;
}
}
输出结果:
S1
S2
S3