Lists 是google 开发的一个类别
其中有一个static method source Code 如下
public static <E> ArrayList<E> newArrayList() {
return new ArrayList<E>();
}
使用上如果我需要宣告一个
通常会这样写
List<myObj> myList = new ArrayList<myObj>();
但使用 Lists google 开发的API 只需要这样写
List<myObj> myList = Lists.newArrayList(); //就可以了
执行到这段时 会自动配好型态指定为 myObj的list给myList
也就是说可以让程式码看起来干净不少。
这边想请教一下 关于这个method 泛型的知识
public static <E> ArrayList<E> newArrayList()
有两个<E> 我想知道 第一个 <E> 代表的意思是??
感谢