public class MyClass { // Declare the array as a class variable private int[] myArray; // Constructor to initialize the array public MyClass(int size) { myArray = new int[size]; // Initialize the array with the given size } // Method to set values in the array public void setValue(int index, int value) { if (index >= 0 && index < myArray.length) { myArray[index] = value; } } // Method to get values from the array public int getValue(int index) { if (index >= 0 && index < myArray.length) { return myArray[index]; } return -1; // Return an invalid value if index is out of bounds } }