+ 2
What's Difference Between These Statements is this same?
public static void main(String[ ] args) public static void main(String [ ]args) public static void main(String args [ ])
5 Answers
+ 13
1D Array Declaration
-------------------------------
int a[] ;
int[] a;
int []a;
=>All are valid
2D Array Declaration
--------------------------------
int[][] a;
int[][] a;
int a[][];
int[] []a;
int[] a[];
int []a[];
=>All are valid
3D Array Declaration
--------------------------------
int [][][]a;
int[][][] a;
int a[][][];
int[] [][]a;
int[] a[][];
int[] []a[];
int[][] []a;
int[][] a[];
int []a[][];
int [][]a[];
=>all are valid
But Make sure that here some example to find dimension of the variable
1)int[] a,b; => { a=1D , b=1D }
2) int[] a[] , b; => { a= 2D , b= 1D (note it ) }
3) int [] []a , b; = { here a= 2D , b = also.
2 D}
=>Be careful about 2nd and 3 rd example
now last and very dangerous example
4)int [] a , b[];
5)int[][] a, []b;
these two are generate compile time error
conclusion
=>if we want to specify the the dimension before or after the variable .this rule is applicable only for 1st variable.
+ 4
All the same
+ 2
also can: public static void main(String [] args) <-- JVM read it as same
0
Thanks for clearing Doubt đ