This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
we can understand this as int a=null; intb=null ;
since a two dimensional array can be written as intb or intb or int b all these declarations are valid .Also,
we can't make reference of two dimensional array to point one dimensional array,as both are totally diffent object. hence we are getting compilation error at line
[ November 07, 2008: Message edited by: Prabhat Gupta ]
Henry Zhi Lin
Joined: Nov 04, 2008
Thanks for your answer, I understand your point, but this puzzled me because when I tested in Eclipse, it does not return any errors and prints null. I guess the compiler of my Eclipse indeed treats this code separately as two one dimension array. [ November 07, 2008: Message edited by: Henry Zhi Lin ]
There is no such thing in Java as a 2-dimensional array, but there is such a thing as an array of arrays, eg int. That is an array of arrays. There is a way of creating an array and an array of arrays in the same statement
int a = null, b = null;
That is probably what you thought you wrote, and in combination with the rest of your code will produce an error.
By the way: I would regard that bit of code as obscure and hard to read and bad style.