Java Object Compare areEqual(final Object o1, final Object o2)

Here you can find the source of areEqual(final Object o1, final Object o2)

Description

Determines equality of the supplied objects by delegating to their hashCode methods.

License

Open Source License

Parameter

Parameter Description
o1 to test equality of
o2 to test equality of

Return

whether o1 equals o2

Declaration

public static boolean areEqual(final Object o1, final Object o2) 

Method Source Code

//package com.java2s;
/* See LICENSE for licensing and NOTICE for copyright. */

public class Main {
    /**// w  w  w .  ja v a  2  s  .c  o m
     * Determines equality of the supplied objects by delegating to their hashCode methods.
     *
     * @param  o1  to test equality of
     * @param  o2  to test equality of
     *
     * @return  whether o1 equals o2
     */
    public static boolean areEqual(final Object o1, final Object o2) {
        if (o1 == null) {
            return o2 == null;
        }
        return o2 != null && (o1 == o2 || o1.getClass() == o2.getClass() && o1.hashCode() == o2.hashCode());
    }
}

Related

  1. areEqual(final Object first, final Object second)
  2. areEqual(final Object object0, final Object object1)
  3. areEqual(final Object x, final Object y)
  4. areEqual(final T object1, final T object2)
  5. areEqual(Object aThis, Object aThat)