public class ArrayOperations { public static void main(String[] args) { // Initializing an array int[] numbers = { 5, 12, 8, 3, 15 }; // Accessing elements System.out.println("Element at index 2: " + numbers[2]); // Finding the length of the array System.out.println("Length of the array: " + numbers.length); // Modifying an element numbers[1] = 20; // Printing the array System.out.print("Modified array: "); for (int i = 0; i < numbers.length; i++) { System.out.print(numbers[i] + " "); } System.out.println(); // Finding the maximum element int maxElement = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > maxElement) { maxElement = numbers[i]; } } System.out.println("Maximum element: " + maxElement); // Finding the minimum element int minElement = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < minElement) { minElement = numbers[i]; } } System.out.println("Minimum element: " + minElement); // Iterating through the array to calculate the sum int sum = 0; for (int num : numbers) { sum += num; } System.out.println("Sum of elements: " + sum); } }