Array
int[] anArray = new int[10];
int[] int_array = { 1, 2, 3 };
String[] str_array = new String[3];
String[] str_array2 = new String[] { "A", "B", "C" };
// fill
long[] long_array = new long[5];
Arrays.fill(long_array, 30);
int[] int_array2 = new int[5];
Arrays.fill(int_array2, 0, 3, -50);
/// copy
int[] int_array3 = {1,2,3,4,5};
int[] copy = Arrays.copyOf(int_array3, 5);
// sort
int[] needSort = new int[] {10,-2,3,-14,5};
Arrays.sort(needSort);
String[] needSortString = new String[] {"A", "E", "Z", "B", "C"};
Arrays.sort(needSortString, 1, 3, Comparator
.comparing(String::toString)
.reversed());
// search
int[] binArray = new int[] {1,2,3,4,5};
int index = Arrays.binarySearch(binArray, 4);
List
List<Integer> aList = Arrays.asList(array);
List<String> cities = new ArrayList() {{
add("New York");
add("Rio");
add("Tokyo");
}};
Set
Set<String> set = Set.of("India", "USSR", "USA");
标签:String,int,long,Arrays,集合,new,array
From: https://www.cnblogs.com/alfredxing/p/17998006/ji-he-lei