Java Object Equal objectsEqual(T a, T b)

Here you can find the source of objectsEqual(T a, T b)

Description

Compares if two objects are equal, handling the cases where one of both of them may be null

License

Apache License

Parameter

Parameter Description
obj1 a parameter
obj2 a parameter

Declaration

public static <T> boolean objectsEqual(T a, T b) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from www .  j ava2s .  com*/
     * Compares if two objects are equal, handling the cases where one of both of them may be null
     * @param obj1
     * @param obj2
     * @return
     */
    public static <T> boolean objectsEqual(T a, T b) {
        return (a == b) || (a != null && a.equals(b));
    }
}

Related

  1. objectsEqual(Object a, Object b)
  2. objectsEqual(Object lhs, Object rhs)
  3. objectsEqual(Object o1, Object o2)
  4. objectsEqual(Object o1, Object o2)
  5. objectsEqual(Object obj1, Object obj2)
  6. safeEquals(Object o1, Object o2)