如下:
@Test
public void test5(){
int[] array = {1, 2, 5, 5, 5, 5, 6, 6, 7, 2, 9, 2};
/*int[]转list*/
//方法一:需要导入apache commons-lang3 jar
List<Integer> list = Arrays.asList(ArrayUtils.toObject(array));
//方法二:java8及以上版本
List<Integer> list1 = Arrays.stream(array).boxed().collect(Collectors.toList());
/*list转int[]*/
//方法一:
Integer[] intArr = list.toArray(new Integer[list.size()]);
//方法二:java8及以上版本
int[] intArr1 = list.stream().mapToInt(Integer::valueOf).toArray();
}
标签:Java,int,list,List,Integer,array,方法
From: https://www.cnblogs.com/lixuejian/p/17092679.html