Programming Tips - Java: How to initialize an array

Date: 2011mar30 Language: Java Keywords: init Q. Java: How to initialize an array A. I do it this way:
int[] myArray = { 1, 2, 3 }
which is nice and compact. Some books tell you to do:
int[] myArray = new int[] { 1, 2, 3 };
which works but is more verbose. Initialize a 2D array in this way:
int[][] twoDimArray = { {1,2,3}, {4,5,6}, {7,8,9} };