javaclass

tests/ArrayTest.java

163:f71be46f1596
2005-01-27 Paul Boddie Added SecureClassLoader declaration.
     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