18.Java泛型(泛型类)

public class Generics '<'E'> '{//去掉前面的单引号

private E e;

public E getE() {

return e;

}

public void setE(E e) {

this.e = e;

}

public static void main(String[] args) {

Generics  d = new Generics();

d.setE(new String("叶苏写的博文"));

System.out.println("该字符串值为:"+d.getE());

}

    

}

猜你喜欢

转载自blog.csdn.net/qq_38983577/article/details/79706485