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

Schulz, Stefan schulz at e-spirit.de
Fri Oct 2 08:31:38 UTC 2009

> Joe Darcy wrote:
> * null safe two-argument equals method
> +    public static boolean equals(Object a, Object b) {
> +        return (a == b) || (a != null && a.equals(b));
> +    }

While I agree this being helpful, as I earlier stated, it would be nice to have a (additional?) method that takes arrays into account as well, as equals() only does an identity check on arrays. In the current situation, one has to check for arrays before using either equals() or Arrays.deepEquals(), which makes Object.equals() pointless as identity and null-check are already done.


More information about the core-libs-dev mailing list