javaclass

tests/ArrayTest.java

166:fed5a5ceb0e6
2005-02-13 Paul Boddie Introduced initial measures for handling circular imports/references.
     1 public class ArrayTest {     2     public int[] array;     3      4     public ArrayTest(int size) {     5         array = new int[size];     6     }     7      8     public int get(int index) {     9         return array[index];    10     }    11     12     public static void main(String[] args) {    13         ArrayTest test = new ArrayTest(10);    14         if (test.array.length != 10) {    15             System.err.println("test.array.length failed!");    16         } else {    17             System.out.println("test.array.length correct: " + test.array.length);    18         }    19         for (int i = 0; i < test.array.length; i++) {    20             test.array[i] = i + 10;    21         }    22         for (int j = 0; j < test.array.length; j++) {    23             if (test.get(j) != j + 10) {    24                 System.err.println("test.get(" + j + ") failed!");    25             } else {    26                 System.out.println("test.get(" + j + ") correct: " + test.get(j));    27             }    28         }    29     }    30 }    31     32 // vim: tabstop=4 expandtab shiftwidth=4