/** Diese Klasse testet zwei-dim. Felder. */ public class TwoDimTest { /** Diese Methode testet zwei-dim. Felder. �berschreiten der Feldgrenzen l�st eine "out of bounds"-Ausnahme aus. */ public static void main (String[] args) { char[][] tastenwert = { {'*', '0', '#'}, //..[0][0],[0][1],[0][2] {'7', '8', '9'}, //..[1][0],[1][1],[1][2] {'4', '5', '6'}, //..[2][0],[2][1],[2][2] {'1', '2', '3'} //..[3][0],[3][1],[3][2] }; System.out.println("tastenwert.length = " + tastenwert.length); // = 4 System.out.println("tastenwert[0].length = " + tastenwert[0].length); // = 3 System.out.println("tastenwert[3][0] = " + tastenwert[3][0]); // = '1' System.out.println("tastenwert[0][2] = " + tastenwert[0][2]); // = '#' int[][] a = {{1}, {2,3}, {3,4,5}}; System.out.println("a.length = " + a.length); // = 3 System.out.println("a[0].length = " + a[0].length); // = 1 System.out.println("a[1].length = " + a[1].length); // = 2 System.out.println("a[0][0] = " + a[0][0]); // = 1 System.out.println("a[1][1] = " + a[1][1]); // = 3 System.out.println("a[2][2] = " + a[2][2]); // = 5 // Exception:"out of bounds": // System.out.println("a[0][1] = " + a[0][1]); // Syntaxfehler: // System.out.println("tastenwert[0,2] = " + tastenwert[0,2]); } }