Harvinder Singh Ji
Sat Sri Akal!
------------------------------------------------
//why compiler accept this without any error.?
int a3[][] = {{1,2},new int[]{3,4,5}};
-------------------------------------------------
In the book by Khalid Moghul, Chapter 4, there is a concept of "Anonymous Arrays" which kind of explains the
new int[]{3,4,5}}; form of array construction, which I guess is bothering you. Basically, this form returns a simple array but you don't have to name it or specify its type. It returns a reference which can be assigned to some appropriate array reference variable or passed as argument to a method etc.
And as for the second part of your question:
I think the array a[3]
has the size 3.But in the Chisholm answers from where this code was taken the size of a3[][] is said to be 4
Well I believe the size of a[3] should be 2, not 3, not 4. It has references to 2 arrays when it was constructed. So thats the length for it.
Cheers
Anupreet