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