Java Object Compare areEqual(final Object object0, final Object object1)

Here you can find the source of areEqual(final Object object0, final Object object1)

Description

Whether two objects are equal, without throwing a null pointer exception.

License

Open Source License

Parameter

Parameter Description
object0 first object we are comparing
object1 second object we are comparing

Return

true if they are the same, false otherwise

Declaration

public static boolean areEqual(final Object object0, final Object object1) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  ww w .  ja va  2s  . co m
     * Whether two objects are equal, without throwing
     * a null pointer exception.
     * @param object0 first object we are comparing
     * @param object1 second object we are comparing
     * @return true if they are the same, false otherwise
     */
    public static boolean areEqual(final Object object0, final Object object1) {
        if ((object0 == null) && (object1 == null)) {
            return true;
        }
        if ((object0 == null) || (object1 == null)) {
            return false;
        }
        return object0.equals(object1);
    }
}

Related

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