alist使用

我们通常会用asList来将数组转成list,但需要主意下面几点:
1、只能用于包装类,不能用基本数据类型
public static void main(String[] args) {
Integer[] ints = {1,2,3};
List<Integer> asList = Arrays.asList(ints);
}
2、通过asList得到的list是不能扩展的list。不能进行add、remove操作。

猜你喜欢

转载自liaopeng.iteye.com/blog/2390588