陣列相關
阿新 • • 發佈:2020-07-27
Arrays.sort()
index=Arrays.binarySearch(array,2)
分段陣列複製
System.arraycopy(original,
0
, destination,
0
, index);
陣列反轉
Collections.reverse(arrayList);
陣列最大值,最小值
int
min = (
int
) Collections.min(Arrays.asList(numbers));
int
max = (
int
) Collections.max(Arrays.asList(numbers));
arraytoList:List list =
new
ArrayList(Arrays.asList(a));
list.addAll(Arrays.asList(b));
數組合並
Object[] c = list.toArray();
陣列填充
Arrays.fill(array,
100
);
Arrays.fill(array,
3
,
6
,
50
);
起點結束點,結束點不包括
陣列擴容:
System.arraycopy(names,
0
, extended,
0
, names.length);
前面貼上到後面
ArrayList.remove()
ArrayList.removeAll() 求差
objArray2.add(0,"common1"); objArray2.add(1,"common2"); objArray2.add(2,"notcommon"); objArray2.add(3,"notcommon1"); objArray.add(0,"common1"); objArray.add(1,"common2"); objArray.add(2,"notcommon2"); System.out.println("array1 的元素" +objArray); System.out.println("array2 的元素" +objArray2); objArray.removeAll(objArray2);
ArrayList.retainAll () 求交集
ArrayList.contains()
Arrays.equals(a,b)