数组转链表,链表转数组

一、数组转链表:
整形
Integer[]a = {2,5,3,1,10,4,443,787,7684,46,74,4-424,4343,4,-4,34,54};
List s = Arrays.asList(a);
浮点型
Double[]a = {2d,5d,3d,1d,10d,4d,443d,787d,7684d,46d,74d,-424d,4343d,4d,-4d,34d,54d};
List s = Arrays.asList(a);
字符串型
String[]a = {“sfs”,“hello”,“world”};
List s = Arrays.asList(a);
字符型
Character[]a = {‘s’,‘d’,‘f’};
List s = Arrays.asList(a);

二、链表转数组

String[]a = {“sfs”,“hello”,“world”};
List list = Arrays.asList(a);
int size = list.size();
String[] arr = list.toArray(new String[size]);
System.out.println(Arrays.toString(arr));

你可能感兴趣的:(数组转链表,链表转数组)