Hai All, Please have a look at the following code.
class Test { public static void main(String[] args) throws Throwable { int ia[][] = { { 1 , 2}, null };//line1 int ja[][] = (int[][])ia.clone(); System.out.print((ia == ja) + " "); System.out.println(ia[0] == ja[0] && ia[1] == ja[1]); } } Can we assign a null value to the array of int type.
Originally posted by sudha siva: Hai All, Please have a look at the following code.
class Test { public static void main(String[] args) throws Throwable { int ia[][] = { { 1 , 2}, null };//line1 int ja[][] = (int[][])ia.clone(); System.out.print((ia == ja) + " "); System.out.println(ia[0] == ja[0] && ia[1] == ja[1]); } } Can we assign a null value to the array of int type.
Thanks sudha
Yes. Since all arrays are also objects, you can initialize an array with a null reference.
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.<br />- Dr. Seuss
Sudha, The code is declaring and initialzing an array of array. So, each of the first arrays' elements will hold reference to the inner (second dimensional) array. And that's where null is pointing to. HTH
Array is inherited from the Object class. So we can have the null value. -SR
Originally posted by Uday Kumar: Sudha, The code is declaring and initialzing an array of array. So, each of the first arrays' elements will hold reference to the inner (second dimensional) array. And that's where null is pointing to. HTH