String S[] = new String[3];
String[] S = new String[3];
Both ways are proper in Java. Does it mean that for every type Type[] x
is the same as Type x[]
?
The difference is if you declare multiple variables on the same line:
String A[], B, C;
would result in A being an array of Strings, whereas B and C are Strings.
String[] A, B, C;
would result in A, B and C all being arrays of Strings.
yes both are same. but
String[] s;
is more readable because If you have thousand line of code some time
you may read String s[]
like String s
;
but in String[] s
you will read as proper String array.
Also if you declare multiple varialbes in one line
like String[] x,y,z;
and String x[],y,z;
you can read the difference easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With