public class W09N03 { // variables private int[] ia; // constructor // @param len the length of the array public W09N03(int len) { // initialize the variable // create array object ia = new int[len]; // give each element a value == to the index // of the element for (int i = 0; i < ia.length; i++) { ia[i] = i + 10; } } // Methods: // search for an int in an int array public int indexOf(int t) { // look through all elements for (int i = 0; i < ia.length; i++) { // if element == t if (ia[i] == t) // return index return i; } return -1; } // A Driver method in the same class being driven // A very common way to test the functionality of the classes you write public static void main(String[] args) { // declare a variable to hold a reference W09N03 w; // create a new object using this class // pass 4 to the constructor w = new W09N03(4); // search for a value by calling the indexOf method // notice this is NOT the indexOf method declared in the String class, // but it behaves in a similar manner int rslt = w.indexOf(13); // should return 3 rslt = w.indexOf(3); // should return -1 } }