What methods should go into a java.util.Objects class in JDK 7?

Joe Darcy Joe.Darcy at Sun.COM
Wed Sep 9 20:40:48 UTC 2009


Hello.

For JDK 7, I think it is high-time the platform included a class like 
java.util.Objects to hold commonly-written utility methods.  For 
example, a two-argument static equals method that returned true if both 
arguments are null, returns false is one argument is null, and otherwise 
returns the result of calling arg1.equals(arg2)  (6797535 "Add shared 
two argument static equals method to the platform").

A static hashCode method returning 0 for null and the value of 
arg.hashCode() has also been suggested.

A set of

    static int compareTo(int, int)
    static int compareTo(long, long)
    ....

methods probably belongs somewhere in the platform too.

What other utility methods would have broad enough use and applicability 
to go into a common java.util class?

-Joe



More information about the core-libs-dev mailing list