Objects.toString [Re: What methods should go into a java.util.Objects class in JDK 7?]

Joseph D. Darcy Joe.Darcy at Sun.COM
Thu Oct 8 18:30:29 UTC 2009

Paul Benedict wrote:
>>> Why would you choose to return "null" for any null object?
>> Because that is how the platform has always treated null in string
>> concatenation.
> If you were defining new operations for String, StringBuilder, or
> StringBuffer, I would agree with your choice. Since you are now
> defining a global utility method for all objects, I think having
> "null" being the de-facto string representation of null is simply
> taking it too far.

System.out.println("" + referenceOfAnyType);

will print "null" if referenceOfAnyType is null.

This is what the platform has done since the beginning.


More information about the core-libs-dev mailing list