hi.. in one question...
class MWC212 {
public static void main(
String[] args) {
int[] a1[],a2[]; // 1
int []a3,[]a4; // 2
int []a5,a6[]; // 3
int[] a7,a8[]; // 4
}}
A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. None of the above
the answer is "b"
with explanation...
An array variable is declared by placing brackets after the identifier or after the type name. A compile-time error occurs at the line marked 2, because the brackets appearing before the identifier for array variable a4 are not associated with the type or the identifier.
so is that means that
int []a5,a6[]; // 3
int[] a7,a8[]; // 4
.............
in above int []a5 is equalant to int[] a5
I mean is it does'nt matter that [] ( square brackets ) attached immediately before a5 in ( int []a5) valid as compare to explanation given by DAN ?
pls do give me suggesion..... got bit confused
regards,
amit