在Arrays.asList()引发的问题中进一步学习集合与泛型等内容
前言
最近在网上看到一个问题,情况类似如下(记为问题1):
public class Demo { public static void main(String[] args) {
System.out.println(testInteger(1));
System.out.println(testInt(1));
} public static boolean testInteger (Integer num) {
Integer[] nums = new Integer[]{1, 2, 3, 4, 5, 6};
boolean flag = Arrays.asList(nums).contains(num);
return flag;
} public static boolean testInt (int num) {
int[] nums = new int[]{1, 2, 3, 4, 5, 6};
boolean flag = Arrays.asList(nums).contains(num);
return flag;
}
}
结果第一个输出为true,提问者觉得很正常,第二个输出却为false了,很奇怪。如果没有深入使用过该集合,或是理解泛型,在我的第一眼看来,也是有疑惑。按理来说,Java中本身针对基本类型与对应包装类型,就有自动装箱拆箱功能,你Integer能行,我int按理来说应该也能行。于是我大致在网上搜寻了类似的问题,发现除了上面的问题,还有类似如下的情况(记为问题2)
public class Demo2 { public static void main(String[] args) {
Integer[] nums1 = new Integer[]{1, 2, 3, 4, 5, 6};
List list1 = Arrays.asList(nums1);
list1.set(0, 888);
System.out.println(list1); int[] nums2 = new int[]{1, 2, 3, 4, 5, 6};
List list2 = Arrays.asList(nums2);
list2.set(0, 888);
System.out.println(list2);
} }
第一个输出正常,集合list1中第一个元素修改为888,但是第二输出还没到就已经报错,完整运行结果如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA7QAAAB5CAYAAAAJWW1ZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAADAbSURBVHhe7Z1NkuS2rkZrW10Lyn3cFbg20BF3FbWKF+GRRx09tWee3mE+USkqKQogAeonJeVxRIe7qygKPIQkfgRIftyt/33f7h8//rj/ysr/+uPH/ePj4377nv3i/qP7+cfH7T75VagnLRz+LV3fVafWPVzz44/cmu/7LdyzUr9ab2dpf/3Yzl/3P35kbfj1x9Cu7D4le8drKizi/SfMHjb8+CFz/r4J7K19GssN9s15xvYr9zC2a5V+LLDJfSzeb94eK5iHH4jXi6x8f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s1Es3iY1WLt29mzauGqXd9O6nrvyZJnzqZuxjPNHZfThzFwhAAAIQgMBAAEGLK5yHQC06e56WYOmrCCw9i/dVdu923xDBzdOAY/TanqK8m7lHuxFrZ4/WI9gDAQhAAAJvQABB+wadfOom5qmopPGdujtfb3ySPr7Gzs+vb9DKFujrRoubIK1sxSmrk3Y8P2VDMBoCEIAABCBwLgII2nP11/tZmwpaaV3n+xGhxYsJBFE7XUsrnaHKz8JGVPypMXi649yvFrsqFUAAAhCAAAQgUCWAoK0iogAEIAABCEAAAhCAAAQgAAEIHJEAgvaIvYJNEIAABCAAAQhAAAIQgAAEIFAlgKCtIqIABCAAAQhAAAIQgAAEIAABCByRAIL2iL2CTRCAAAQgAAEIQAACEIAABCBQJYCgrSKiAAQgAAEIQAACEIAABCAAAQgckQCC9oi9gk0QgAAEIAABCEAAAhCAAAQgUCWAoK0iogAEIAABCEAAAhCAAAQgAAEIHJEAgvaIvYJNEIAABCAAAQhAAAIQgAAEIFAlgKCtIqIABCAAAQhAAAIQgAAEIAABCByRAIL2iL2CTRCAAAQgAAEIQAACEIAABCBQJYCgrSKiAAQgAAEIQAACEIAABCAAAQgckQCC9oi9gk0QgAAEIAABCEAAAhCAAAQgUCWAoK0iogAEIAABCEAAAhCAAAQgAAEIHJEAgvaIvYJNEIAABCAAAQhAAAIQgAAEIFAlgKCtIqIABCAAAQhAAAIQgAAEIAABCByRAIL2iL2CTRCAAAQgAAEIQAACEIAABCBQJYCgrSKiAAQgAAEIQAACEIAABCAAAQgckQCC9oi9gk0QgAAEIAABCEAAAhCAAAQgUCWAoK0iogAEIAABCEAAAhCAAAQgAAEIHJEAgvaIvYJNEIAABCAAAQhAAAIQgAAEIFAlgKCtIqIABCAAAQhAAAIQgAAEIAABCByRwP8DxdPz9ZvM9EAAAAAASUVORK5CYIIA" alt="" />
java.lang.ArrayStoreException:数组存储异常。下面具体就集合方法与泛型探究上面的问题。
过程
Integer[] nums = new Integer[]{1, 2, 3, 4, 5, 6};
Arrays.asList(nums);进入这个方法,源代码如下:
public static <T> List<T> asList(T... a) {
return new ArrayList<>(a);
}
短短的两行代码,内容却并不简单
1.方法的参数比较特殊:参数是泛型类的,并且是可变参数。一个泛型,一个可变参数,说实话,初学者或者开发中不敢说都没用过,但要是说有多常用,显然也不符合。所以其实上面的内容在这一步就已经出问题了,下面会具体分析。
2.方法的返回值是一个ArrayList,这里又是一个大坑,这个ArrayList并不是我们以前学习或者平时常用到的有序集合ArrayList,而是数组工具类Arrays类的一个静态内部类,继承了AbstractList,如下所示:
private static class ArrayList<E> extends AbstractList<E>
implements RandomAccess, java.io.Serializable
{
private static final long serialVersionUID = -2764017481108945198L;
private final E[] a; ArrayList(E[] array) {
//上面调用的构造方法内容即为这里,调用requireNonNull方法,对象array为空的话会报空指针异常,不为空则将其赋值给成员a。
a = Objects.requireNonNull(array);
} //赋值后此时a就代表了array数组的内容,所以后面的方法基本上都围绕a展开。 @Override
public int size() {
return a.length;
} @Override
public Object[] toArray() {
return a.clone();
}
...... }
requireNonNull方法内容:
public static <T> T requireNonNull(T obj) {
if (obj == null)
throw new NullPointerException();
return obj;
}
完整的过完了这一遍流程后,我们要思考的是,通过Arrays.asList(nums)方法,我们得到的到底是一个什么。从上面的内容,我们首先可以确定是一个集合。在问题1中,包装类Integer情况下,调用Arrays.asList(nums),基于可变参数的定义,这里我们相当于传入可变参数的长度为5。
在public static <T> List<T> asList(T... a)方法中,此时相当于泛型T指定为Integer类型。然后private final E[] a; 此时的数组a的泛型E也相应为Integer。此时a的内容相当于 new Integer[]{1,2,3,4,5,6}; 即一个Integer类型的一维数组,集合也随之为List<Integer>
最后获取的是一个Arrays的一个静态内部类ArrayList对象,在内部类中重写了contains方法:
@Override
public boolean contains(Object o) {
return indexOf(o) != -1;
}
所以在问题1中的第一种情况传入1时会自动转为对象Object类型,即上面的o,此时显然成立,所以返回true。
那么第二种情况输出false,问题出在哪里?
在基本类型int情况时,同样基于可变参数的定义,同时基于java的自动转换类型,跟上面一样传入可变参数的长度还是相当于5吗?其实不是,根本原因在于这里除了可变参数的定义,还有泛型的定义,但是别忘了泛型也有一些限制,首先第一点就是:
泛型的类型参数只能是类类型(包括自定义类),不能是简单类型!
所以这里其实就已经有分歧了,所以这里我们相当于传入了一个对象,对象类型为数组类型,可变参数的长度是1,而不是5。此时a相当于一个二维数组,在上面的情况中,即a数组的元素类型为数组,元素个数为1,而不是上面的Integer,此时集合为List<int[]>。
最后得到的集合是这样子:List<int[]>形式,集合长度为1,包含了一个数组对象,而不是误以为的List<Intger>。
接着调用contains方法,集合中就一个数组类型对象,显然不包含1。所以问题1中int情况下输出false
同样的,在问题2的int情况下,list2.set(0,888);即相当于将集合索引为0的元素(即第1个,这里集合中就一个数组元素)赋值为一个888自动转型的Integer类,给1个数组Array类型对象赋值Intger对象,所以才报错了上面的数组存储异常。
梳理与验证
为了更好的理清上面的内容,做如下扩展。
首先是Integer对象类型。
Integer[] nums = new Integer[]{1, 2, 3, 4, 5, 888};
List<Integer> list2 = Arrays.asList(nums);
System.out.println(list2.get(5));//输出888
这里我们顺利的通过一次索引拿到在这个888。
接着是int基本类型,前面提到了既然是可变参数,我们传了一个数组,一个数组也是一个对象,那我们可以传入多个数组看看,如下所示。
int[] nums1 = new int[]{1, 2, 3, 4, 5, 666};
int[] nums2 = new int[]{1, 2, 3, 4, 5, 777};
int[] nums3 = new int[]{1, 2, 3, 4, 5, 888};
List<int[]> list1 = Arrays.asList(nums1,nums2,nums3);
System.out.println(list1.get(2)[5]);//输出888
这里的get方法我们点进去查看源代码:
@Override
public E get(int index) {
return a[index];
}
所以这里我们输出其实就是a[2][5],拿到888,这也印证了前面为什么说本质上就是一个二维数组的原因,同时加深了我们对集合与数组关系的理解。
更多的陷阱
前面重点提到这里我们通过Arrays.asList()方法得到的"ArrayList",并不是我们平时常用的那个ArrayList,既然强调了,当然是为了要区分,那么不区分会有什么问题呢,下面以简单的Integer情况为例:
Integer[] nums = new Integer[]{1, 2, 3, 4, 5};
List<Integer> list = Arrays.asList(nums);
list.add(888);
System.out.println(list);
集合后面加个888,觉得会打印出来什么?【1, 2, 3, 4, 5,888】?
然后事实是还没到打印就已经抛出异常了,如下所示:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAx0AAABOCAYAAABFa3tXAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAACY1SURBVHhe7V1NbuU6zq11ZUHZR+0gGwjwVpFVfECNelSoafXsTXuYz/I1fWmJFEnZ8t89BQSvO5El6pCyeURS+vHN/v3zzz/f+AEGsAHYAGwANgAbgA3ABmADsAHYwJY28IOTDvxvIAAEgAAQAAJAAAgAASAABIDA1giAdGyNKPoDAkAACAABIAAEgAAQAAJAYIEASAcMAggAASAABIAAEAACQAAIAIGuCIB0dIUXnQMBIAAEgAAQAAJAAAgAASAA0hGxgY+37+8fA2TvX5Gnjmt7NXmPQwoj5whc0nb+9/3x8/++f7z/5/vjv1ApEAACQOA8CPz++s/wbhreT5//nkeoF5UEujhO8SAdbux/f3+/DXAl0vHj3f3UcQ0vIi85txfhcao+vwabSLaxZh7vk30Rqc3//27G1MF29pjbf/9+v6WP+vDz9vW/3dDqM9C/3+/TXEZHBc5KH5jR63oEfv0Z7fP91/qu7tsDbYiktfxn1WfivhjtNTPoYi+kpXEqpGPwnkYHW/lZ41wdOWM+9ugIBQjE1XZ/j5bXgy9Ix9Mic32Ro/4xkIC9/21tO7vM7U6RjruSjmleP/9+l1Y96U/8294L4PrjfX3u5OBWSMdDBvZzI91G8T1ud114lzCd3IEsXkcX13+vrJ0BSEeEdKxF+9WeB+mIaZwccyIZ+f+P9Xau1neeW3ekJ6fhFmkZIB3dzWUaIOqINcslkg6+m5wRj5vs9O+Gb7Ni6EGQjtUQooPNELBJx1XqF1og8TjFLf3imQcCHnwR6SgjHSAdWEELBEA6YBBxBHZzigXSMe/qZ5GNOfJxAwK9G75x1WdP3On9IYNxHV2sVublO9iAdLA0rDzl6vfHlJ41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yOW9BNsTg3tGOr4+J13//Ps9rJTsn37fw3wsq/QcLkyzTRYtgAAQeDkEQDqupHKQjoO1VSEdiXic8YKkedd1IkdEktJ/u6UtHawma3jCRCReOukYnUzRMbUG7Pz3X3/0M/k//+08+HW7n8kG3emwJelIsBBpPvWGxHX1B8mBABC4HgL/D/M4vCLwrWHCAAAAAElFTkSuQmCCAA==" alt="" />
java.lang.UnsupportedOperationException:不支持的操作异常。为什么会不支持,我们以前一直add,remove等等都没问题。深究到底查看源代码。
首先java.util包下的ArrayList即我们熟知的,它的add方法实现如下:
public boolean add(E e) {
ensureCapacityInternal(size + 1); // Increments modCount!!
elementData[size++] = e;
return true;
}
这也是我们一直以来操作没毛病的原因。
再来看这个"ArrayLitst",它在继承抽象类AbstractList的时候,并未实现(或者准确来说叫做重写)add方法,所以这里在调用add方法的时候,实际上是调用的抽象类AbstractList中已经实现的add方法,我们来看其方法内容:
public boolean add(E e) {
add(size(), e);
return true;
}
通过add(size(), e);这个传入2个参数的方法我们继续查看内容:
public void add(int index, E element) {
throw new UnsupportedOperationException();
}
真相大白!throw new UnsupportedOperationException();这个异常从哪来的一目了然。这个"ArrayLitst"根本没有实现add方法,所以才会报错。回到初始,还能想起集合与数组的种种关联,数组本身长度就是不可变的,而这里本质上我们就是在操作数组,所以没有add方法不是很正常吗。仔细查看其类的源码,会发现例如remove删除等方法,也是没有实现的,所以同样也会报错。
继续探讨,那么这里增也不行,删也不行,那我改总行吧,就数组而言,按理来说应该是支持的,而实际情况也的确如此。在"ArrayLitst"内部类中,其重写了set方法,方法能将指定索引处的元素修改为指定值,同时将旧元素的值作为返回值返回。
@Override
public E set(int index, E element) {
E oldValue = a[index];
a[index] = element;
return oldValue;
}
但是这里还要注意一点,如果我们在这里针对集合修改了某处元素值,那么原来数组的内容也会相应改变!即通过Arrays.asList()方法,得到的集合与原数组就已经关联起来,反之,如果我们修改了数组内容,那么集合获取到的内容也会随之改变。实践检验一下:
Integer[] nums = new Integer[]{1, 2, 3, 4, 5};
List<Integer> list = Arrays.asList(nums);
list.set(0, 888);//修改集合内容
nums[1] = 999;//修改数组内容
for(Integer i:nums) {
System.out.println(i);
}
System.out.println(list);
运行后,控制台输出如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfwAAAClCAYAAAC5pE+YAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAABL+SURBVHhe7d3bteq4ggXQndYmINI5hFBRkAxf/dMh9K+bl8EP2ZKNxDZo1hhn3Ft1hJCmZC9LNvDzP//7f83lT+if07/f5ufnp/nZH4N/P/6Pp+bf77n8z77pveL0r/m91DPz5/EWx/21XOgt2/aM/u7+mt9/p0GTjs1+2P5A/ZP1nntxff3vv+ZZ8/2/hfrSa9irFoG2d3s34xQarOP+5j82CpS+j9d82Xv/WpsFY/zyOEbad6v/txlNh3tX2/dPsri+5jYWk+WD8y9xngzH8d63/hxPrGviKG3Hfuq4GR3fkbl1q69zjOcoP+EQP/ek2kwcj9fhHZxzFs6vZeeP9v2m5+dtGCPHf+IZuZnqy+Q5M1Dx1PguclpxPpudV2nj/vK5Zso56RwZmFsz8y2ej+0cjpzLZ9r2Mxf4l7Y9Qj8p+CMhl3LhsOnA74J3D9jQZH7VYsUBEjxWnxdayQGXMpnbgG/HdPjvMyeklw/CRSeafkOWh3164D+n95J50h/nW/u6F8xL6gpe6t0uWmf/DMJn9kQbmNc5yq8K/CU2nxb4M+1NDft7uesFWm/R8gyipHPC5gI/fdxfPte8M/BT8rG9EOwcz6ExDI75uS/RwH/09z7o8yv+qUkaWilPLke2u8KfDLUFgR/cNZg5UQ8P1MEqdWqOtKu65FV9twkJgT9eRaeP8esH4fzF0GgFOjBLOsn1hiRthf8Yi0Xz5LLAbFfM9+OnO6gL6xrOpOnV5yMNxjs/s6u/wDivLN+bu6NQSZhPi2wWBH5kdT2cX2VW+M/FVlIOzF0EXG3DF3VJx8LkBd2S43B+PIOGkQuN8e7PuD2v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ABAgQIVCAg8CsYZF0kQIAAAQIC3xwgQIAAAQIVCAj8CgZZFwkQIECAgMA3BwgQIECAQAUCAr+CQdZFAgQIECAg8M0BAgQIECBQgYDAr2CQdZEAAQIECAh8c4AAAQIECFQgIPArGGRdJECAAAECAt8cIECAAAECFQgI/AoGWRcJECBAgIDANwcIECBAgEAFAgK/gkHWRQIECBAg8P+DIyWvrhPnGwAAAABJRU5ErkJgggA=" alt="" />
我们发现,不论是修改数组,还是修改集合,另一方都会相应改变。
小结
一开始以为是一个小问题,渐渐的发现,其中内容不少,集合是我们开发中算是很常用类库了,良好的熟悉程度能对我们的开发优化不少。而泛型关联到反射等等核心内容,如果想深入学习,也需要认真下功夫,在问题的探究中往往能有更深刻的印象。
在Arrays.asList()引发的问题中进一步学习集合与泛型等内容的更多相关文章
- Arrays.asList 存在的坑
引语: 阿里巴巴java开发规范说到使用工具类Arrays.asList()方法把数组转换成集合时,不能使用其修改集合相关的方法,它的add/remove/clear方法会抛出UnsupportedO ...
- Arrays.asList()使用指南
简介 Arrays.asList()在平时开发中还是比较常见的,我们可以使用它将一个数组转换为一个List集合. String[] myArray = { "Apple", &qu ...
- Java集合工具类使用的一些坑,Arrays.asList()、Collection.toArray()、foreach
Arrays.asList() 使用指南 最近使用Arrays.asList()遇到了一些坑,然后在网上看到这篇文章:Java Array to List Examples 感觉挺不错的,但是还不是特 ...
- 工具类Arrays.asList()方法把数组转换成集合
工具类Arrays.asList()方法把数组转换成集合 不能使用其修改集合相关的方法,它的add/remove/clear方法会抛出UnsupportedOperationException() 问 ...
- JAVA基础学习之 Map集合、集合框架工具类Collections,Arrays、可变参数、List和Set集合框架什么时候使用等(4)
package com.itcast.test20140113; import java.util.ArrayList; import java.util.Arrays; import java.ut ...
- Arrays.asList中所遇到的坑
前言 最近在项目上线的时候发现一个问题,从后台报错日志看:java.lang.UnsupportedOperationException异常 从代码定位来看,原来是使用了Arrays.asList() ...
- Java中关于Arrays.asList()的操作
我们可以通过Arrays.asList() 产生一个List,但是要记住,我们通过Arrays.asList产生的list是基于一个固定大小的数组的, 仅支持那些不会改变数组大小的操作.所以我们在使用 ...
- Java中关于Arrays.asList方法的深入学习与理解
Java的标准库中在java.util包下提供了很多实用的工具类,如:Arrays,Collections等工具类都提供了一些比较实用的方法.在实际的开发使用中,我们经常需要使用这样的需求:将一个数组 ...
- 【Java必修课】好用的Arrays.asList也有这三个坑
好用的asList 在开发或写测试用例的过程中,经常会用到Arrays.asList()这个方法,可以快速方便地将数组转化成一个List.例如: List<String> list = A ...
随机推荐
- 两种方法上传本地文件到github
https://www.jianshu.com/p/c70ca3a02087 自从使用github以来,一直都是在github网站在线上传文件到仓库中,但是有时因为网络或者电脑的原因上传失败.最重要的 ...
- vuethink 在本地没问题,在服务器报错 , php5.6与php5.5之间的大坑
将环境换为php5.6即可
- laravel中数据库在哪个文件中配置
我们使用 mysql 数据库,修改 .env: DB_HOST=localhost DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD= 在mysql中创 ...
- JavaSE笔记-泛型
定义带泛型的类 public class Cat<T> { //可以用T定义实例变量 private T name; //可以用T定义形参 //构造器没有<> public C ...
- dedecms_
2012-7-5(no1)当我们点击检索结果的某个电影超链接时,如何跳转到对应的内容页[本资源由www.qinglongweb.com搜集整理] dedelist标签 --可以嵌套 项目移植: mys ...
- Linux的运行级别详细说明
Linux 7个运行级别 # 0 - 停机(千万不要把initdefault设置为0 ) # 1 - 单用户模式 # 2 - 多用户,但是没有NFS # 3 - 完全多用 ...
- 【开发技术】视频URL采集
http://www.joyplus.tv/joypluscms 志精
- Tomcat下的Server.xml配置文件详解
自15年毕业到现在已经入行两年多了,一直以来没有深入的了解过tomcat的详细配置,只懂修改一下端口号.在网上找了些相关资料来支撑这篇文章,深入了解server.xml文件各配置的作用 <?xm ...
- python装饰器实现对异常代码出现进行监控
异常,不应该存在,但是我们有时候会遇到这样的情况,比如我们监控服务器的时候,每一秒去采集一次信息,那么有一秒没有采集到我们想要的信息,但是下一秒采集到了, 而后每次的采集都能采集到,就那么一次采集不到 ...
- NW.js 简介与使用
简介 (1)以网络最流行的技术编写原生应用程序的新方法 (2)基于HTML5, CSS3, JS and WebGL而编写 (3)完全支持nodejs所有api及第三方模块 (4)可以使用DOM直接调 ...