Originally posted by Jose Botella:
But println(Object) was not written for providing a "null" String to the write method when the method toString() of the Object argument returned null.
Hi
I am pasting source code for println(Object obj):
from System.java : public final static PrintStream out = nullPrintStream();
--------------------------------------------------------------
from PrintStream.java : public void println(Object x) {
synchronized (this) {
print(x);
newLine();
}
public void print(Object obj) {
write(String.valueOf(obj));
}
-----------------------------------------------------------------
from String.java : public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString();
}
Now will any one please tell me why NullPointerException should be thrown?
Thanks in adv
------------------
Regards
Ravish