Sort an Array in Java
public class Test { public static void main(String[] args) { int[] array = new int[]{7, 1, 9, 2, 5}; Arrays.sort(array); Arrays.stream(array).forEach(System.out::print); } } Output: 1 2 5 7 9 Note: values of type int will be automatically converted to the corresponding Wrapper class. And since the Integer Wrapper class implements Comparable, we can sort…
Read More Sort an Array in Java