Collections类:
void: Collections.reverse(List list) 反转
void: Collections.shuffle(List list) 随机排序
void: Collections.sort(List list) 按自然排序的升序排序
Arrays类:
判断两个数组是否一样:
boolean: Arrays.equals(str1,str2)
String: Arrays.toString(arr)
void: Arrays.sort(arr)
List和数组相互转换:
1.数组转换成List:
String[] arr = new String[] {"1", "2"};
List<String> list = Arrays.asList(arr);
System.out.println(list);
2.List转换成数组:
List<String> list = new ArrayList<>();
list.add("1111");
list.add("2222");
//创建一个和集合中元素数量一样多的数组
String[] array = new String[list.size()];
list.toArray(array);
System.out.println(Arrays.toString(array));