java use .sort code example
Example 1: java sort method
Arrays.sort();//this method is an inbuild function in java
//to sort the array
Example 2: java sort
javaCopyimport java.util.Arrays;
public class SimpleTesting {
public static void main(String[] args) {
int[] arr = new int[]{12,3,5,21,4,85,6,9,2,1};
for (int i : arr) {
System.out.print(i+" ");
}
Arrays.parallelSort(arr);
System.out.println("\nAfter Sorting...");
for (int i : arr) {
System.out.print(i+" ");
}
}
}