public static void main(String[] args) {
int arr[] = {1,3,5,4,6,2}
ArrayList<Integer> arrInt = new ArrayList<Integer>()
for(int i=0
arrInt.add(arr[i])
}
//sort操作
System.out.println("before sort:"+arrInt)
Collections.sort(arrInt)
System.out.println("after sort:"+arrInt)
//Shuffling操作
System.out.println("before shuffle:"+arrInt)
Collections.shuffle(arrInt)
System.out.println("after shuffle:"+arrInt)
//Reverse操作
System.out.println("before Reverse:"+arrInt)
Collections.reverse(arrInt)
System.out.println("after Reverse"+arrInt)
//Copy操作
ArrayList<Integer> arrInt1 = new ArrayList<Integer>()
int arr1[] = {0,0,0,0,0,0,0}
for(int i=0
arrInt1.add(arr1[i])
}
System.out.println("before copy:"+arrInt1)
Collections.copy(arrInt1, arrInt)
System.out.println("after copy:"+arrInt1)
//min操作
System.out.println("min:"+Collections.min(arrInt))
//max操作
System.out.println("max:"+Collections.max(arrInt))
//lastIndexOfSubList
ArrayList<Integer> arrInt2 = new ArrayList<Integer>()
System.out.println("lastIndexOfSubList:"+Collections.lastIndexOfSubList(arrInt, arrInt2))
//IndexOfSubList
ArrayList<Integer> arrInt3 = new ArrayList<Integer>()
System.out.println("IndexOfSubList:"+Collections.indexOfSubList(arrInt, arrInt3))
//Rotate
System.out.println("before rotate:"+arrInt)
Collections.rotate(arrInt, 2)
System.out.println("after rotate:"+arrInt)
//binarySearch
//replaceAll
System.out.println("before replaceAll:"+arrInt)
Collections.replaceAll(arrInt, 3, 9)
System.out.println("after replaceAll:"+arrInt)
//synchronizedXXX()
Collections.synchronizedCollection(arrInt)
//emptyXXX
Collections.emptyList()
//singletonXXX()
System.out.println("Collections.singleton(1)"+Collections.singleton("1"))
//unmodificableXXX()
System.out.println("Collections.unmodifiableList(arrInt)"+Collections.unmodifiableList(arrInt))
//frequency
System.out.println("Collections.frequency(arrInt, 5)"+Collections.frequency(arrInt, 5))
//Fill操作
System.out.println("before Fill:"+arrInt)
Collections.fill(arrInt, 0)
System.out.println("after Fill:"+arrInt)
}