Mega Code Archive

 
Categories / Java Tutorial / Collections
 

Alternative Array Declaration Syntax

For example, the following two declarations are equivalent: int al[] = new int[3]; int[] a2 = new int[3]; The following declarations are also equivalent: char twod1[][] = new char[3][4]; char[][] twod2 = new char[3][4]; This alternative declaration form offers convenience when declaring several arrays at the same time: int[] nums, nums2, nums3; // create three arrays