Consider below one :
Object nothingToHold = null;
System.out.println(nothingToHold); // Safely prints \'null\'
Here, Sysout must be expe
The PrintStream#println(Object s) method invokes the PrintStream#print(String s) method, which first checks is the if the argument is null and if it is, then just sets "null" to be printed as a plain String.
However, what is passed to the .print() method is "null" as String, because the String.valueOf(String s) returns "null" before the .print() method being invoked.
public void print(String s) {
if (s == null) {
s = "null";
}
write(s);
}