Programming Tips - How do I initialize an array?

Date: 2011mar30 Language: Java Keywords: init Q. How do I 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} };