14.Program to sort the elements of an array in ascending order.
💡Code:
import java.util.Arrays; public class SortArrayAscending7078 { public static void main(String[] args) { // Example array int[] numbers = {15, 7, 23, 45, 9, 56, 82, 31}; // Sort the elements of the array in ascending order sortArrayAscending(numbers); // Print the sorted array System.out.println("Sorted array in ascending order: " + Arrays.toString(numbers)); } // Function to sort the elements of an array in ascending order private static void sortArrayAscending(int[] array) { Arrays.sort(array); } }
📸Output :
.png)