Java Object Equal equals(Object o1, Object o2)

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

Description

Test two objects for equality safely.

License

Open Source License

Declaration

public static boolean equals(Object o1, Object o2) 

Method Source Code

//package com.java2s;
// under the terms of the GNU Lesser General Public License as published

import java.util.Arrays;

public class Main {
    /**//from w  w w.  j a  va2 s.  c  o  m
     * Test two objects for equality safely.
     */
    public static boolean equals(Object o1, Object o2) {
        return (o1 == o2) || ((o1 != null) && o1.equals(o2));
    }

    /**
     * Returns true if the two supplied exceptions have equal messages and
     * equal stack traces.
     */
    public static boolean equals(Throwable t1, Throwable t2) {
        return (t1 == t2) || ((t1 != null) && (t2 != null) && equals(t1.getMessage(), t2.getMessage())
                && Arrays.equals(t1.getStackTrace(), t2.getStackTrace()));
    }
}

Related

  1. equals(final Object a, final Object b)
  2. equals(Object a, Object b)
  3. Equals(Object in1, Object in2)
  4. equals(Object o1, Object o2)
  5. equals(Object o1, Object o2)
  6. equals(Object object1, Object object2)
  7. equals(Object thisObj, Object thatObj)
  8. equals(Object v1, Object v2)
  9. equals(Object x, Object y)