String x = (String) null;
Why there is no exception in this statement?
String x = null;
System.out.println(x);
It prints null
. But .toString()
method should throw a null pointer exception.
String x = (String) null;
Why there is no exception in this statement?
String x = null;
System.out.println(x);
It prints null
. But .toString()
method should throw a null pointer exception.