Just a little smile ^ ^

yoyo_zeng

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

泛型类

public class classname<type1, type2...>{

}

classname n = new classname<String, Integer>();

 

泛型接口

public interface interfacename<type1, type2>{}

 

泛型方法

public <T> void functionname(T t){

}

 

泛型数组

List<T> array = new ArrayList<T>();

 

通配符

List<object> list = new ArrayList<classname>;//error

List<? extends xxx> list= new ArrayList<classextendsxxx>; //无法编译

 

超类通配符

<? super MyClass>

 

数组和泛型不能一起使用

classname<type>[] t = new classname<type>[10]; //error

 

 

posted on 2012-11-16 15:41  yoyo_zeng  阅读(226)  评论(0编辑  收藏  举报