java常用代码
// ArrayList转int数组 int[] arr = list.stream().mapToInt(Integer::valueOf).toArray();
// ArrayList初始化 ArrayList<Type> obj = new ArrayList<Type>(Arrays.asList(Object o1, Object o2, Object o3, ....so on)); ArrayList<T> obj = new ArrayList<T>(Collections.nCopies(count,element));//把element复制count次填入A
// arrayCopy public static native void arraycopy(Object src, int srcPos, Object dest, int destPos,int length);
// 对二维数组按照先按第一个值再按第二个值排序 int[][] arr = new int[][] {new int[] {1, 4}, new int[] {4, 2}, new int[] {3, 7}, new int[] {1, 2}}; Collections.sort(arr, Comparator.comparingInt(t -> ((int[]) t)[0]).thenComparingInt(t -> ((int[]) t)[1]));