Dear Friends,
I have observed this strange question on a site
class Test001
{
int i;
public Test001(int i) { this.i = i; }
public
String toString()
{
if(i == 0) return null;
else return "" + i;
}
public static void main(String[ ] args)
{
Test001 t1 = new Test001(0);
Test001 t2 = new Test001(2);
System.out.println(t1);
System.out.println(t2);
}
}
The answer to this question is NullPointerException instead of
null
2
Can anybody throw some light on it?
THanks
Sri