package ming;class Apple3{ private T info; public Apple3(){} public Apple3(T info){ this.info = info; } public T getInfo() { return info; } public void setInfo(T info) { this.info = info; } }class A1 extends Apple3 { public A1(){} public A1(String info){ super(info); } public String getInfo(){ return "子类"+super.getInfo(); }}class A2 extends Apple3{ public A2(String info){ super(info); } public String getInfo(){ return super.getInfo().toString(); }}public class Apple3Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Apple3 base3 = new Apple3 ("apple"); A1 a1 = new A1("apple"); A2 a2 = new A2("apple"); System.out.println(base3.getInfo()); System.out.println(a1.getInfo()); System.out.println(a2.getInfo()); }}
//A1,A2 为方法1和方法2
//泛型不能有static