javaclass

tests/MultiArrayTest.java

158:a52e70c3f294
2005-01-23 Paul Boddie Added "safety measures" for exception offset insertion, although better measures are necessary to avoid bizarre JDK 1.4 exception tables.
     1 public class MultiArrayTest {     2     public int[][] multiArray;     3      4     public MultiArrayTest(int[] multiSizes) {     5         multiArray = new int[multiSizes[0]][multiSizes[1]];     6     }     7      8     public int get(int index1, int index2) {     9         return multiArray[index1][index2];    10     }    11     12     public static void main(String[] args) {    13         int[] sizes = {4, 7};    14         MultiArrayTest test = new MultiArrayTest(sizes);    15         if (test.multiArray.length != 4) {    16             System.err.println("test.multiArray.length failed!");    17         } else {    18             System.out.println("test.multiArray.length correct: " + test.multiArray.length);    19         }    20         if (test.multiArray[0].length != 7) {    21             System.err.println("test.multiArray[0].length failed!");    22         } else {    23             System.out.println("test.multiArray[0].length correct: " + test.multiArray[0].length);    24         }    25         if (test.multiArray[3][6] != 0) {    26             System.err.println("test.multiArray[3][6] failed!");    27         } else {    28             System.out.println("test.multiArray[3][6] correct: " + test.multiArray[3][6]);    29         }    30         test.multiArray[3][6] = 36;    31         if (test.get(3, 6) != 36) {    32             System.err.println("test.get(3, 6) failed!");    33         } else {    34             System.out.println("test.get(3, 6) correct: " + test.get(3, 6));    35         }    36     }    37 }    38     39 // vim: tabstop=4 expandtab shiftwidth=4