Skip to content

Instantly share code, notes, and snippets.

@CYanLong
Last active November 8, 2016 04:16
Show Gist options
  • Save CYanLong/ffa8cf98af85182ffbb5548ba58e5bf9 to your computer and use it in GitHub Desktop.
Save CYanLong/ffa8cf98af85182ffbb5548ba58e5bf9 to your computer and use it in GitHub Desktop.
Conversion of arrays and collections
/* 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