Last active
November 8, 2016 04:16
-
-
Save CYanLong/ffa8cf98af85182ffbb5548ba58e5bf9 to your computer and use it in GitHub Desktop.
Conversion of arrays and collections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* array 转 list | |
Arrays.asList(T... elem) 返回的是Arrays内部自己实现的List. | |
*/ | |
public void arrayToList(){ | |
int[] array = new int[10]; | |
List<Integer> lists = new ArrayList<Integer>(Arrays.asList(array)); | |
} | |
/*Integer array to int array | |
不会自动装箱,也 无法强转. | |
*/ | |
public void IntegerArrTointArr(){ | |
Integer[] arr1 = new Integer[10]; | |
//.. | |
Arrays.stream(arr1).mapToInt(Integer::intValue).toArray(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment