Collections vs Arrays regarding sort() What is the difference between these two regarding sort() method? I know Arrays\' sort() is using binary search for sort(), what about Co
Collections.sort() Operates on List Whereas Arrays.sort() Operates on an Array.
Arrays.sort() uses Dual-Pivot Quicksort for Primitive Arrays and MergeSort for sorting array of Objects.
Example of Collections.sort() :
ArrayList arr = new ArrayList();
arr.add(15);
arr.add(10);
arr.add(5);
arr.add(2);
Collections.sort(arr);
Example of Arrays.sort() :
int[] arr = new int[4]
arr[0]=15;
arr[1]=10;
arr[2]=5;
arr[3]=2;
Arrays.sort(arr);