Can please someone explain me?
What will happen if you try to compile and run the following code?
public class Q {
public static void main(
String argv[]){
int anar[]=new int[]{1,2,3};
System.out.println(anar[1]);
}
}
1) 1
2) Error anar is referenced before it is initialized
3) 2
4) Error: size of array must be defined
answer:
3 ) 2
I think the array declaration is wrong.
He gave
int anar[]=new int[]{1,2,3};
Correct me if I am wrong.
Thank you in advance.
regards
VR