Alternative Array Declaration Syntax

The square brackets follow the type specifier, and not the name of the array variable.


type[] var-name;

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 d1[][] = new char[3][4]; 
char[][] d2 = new char[3][4];
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.