In Java, I understand that whenever we print a reference to an object, toString () will be called internally. By default, toString () will print in this format "classname @hashcode". If so, then the following snippet should throw a Null Pointer exception. Why is this not happening?
int[][] a = new int[3][];
System.out.println(a); --> Prints [a@xxxxx
System.out.println(a[0]); --> Prints null (It should have thrown Null pointer Exception?)
Can someone help me figure this out?
source
share