java课件丁振凡第14章.pptVIP

  • 2
  • 0
  • 约8.27千字
  • 约 27页
  • 2017-11-18 发布于重庆
  • 举报
java课件丁振凡第14章

Java语言程序设计(第2版) 14.1 Java泛型 ---参数化类型 public class ExampleT { //T为类型参数 private T obj; //定义泛型成员变量 public Example(T obj) { this.obj = obj; } public T getObj( ) { return obj; } 【例14-1】 【例14-1】续 public void showType( ) { System.out.println(T的实际类型是: + obj.getClass( ).getName( )); } public static void main(String[ ] args){ ExampleString str=new ExampleString(Generic class example!); str.showType( ); String s = str.getObj( ); System.out.println(value= + s); } } 泛型在

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档