Opening Hours :7AM to 9PM
import java.util.Arrays; public class Main { public static void main(String[] args) { int[] arr = {3, 6, 1, 2, 5, 4}; Arrays.sort(arr); for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + " "); } } }In this example, the program creates an array arr of integers and assigns it the values {3, 6, 1, 2, 5, 4}. The Arrays.sort(arr) line sorts the array in ascending order. Finally, the program uses a for loop to print out the elements of the sorted array.
import java.util.Arrays; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] args) { Integer[] arr = {3, 6, 1, 2, 5, 4}; ListAdditionally, you can implement your own sorting algorithm, like Bubble sort, selection sort, or insertion sort. These algorithms are based on comparing and swapping the elements of the array.list = Arrays.asList(arr); Collections.sort(list); for (int i : list) { System.out.print(i + " "); } } }