Here you can find the source of equals(Object o1, Object o2)
public static boolean equals(Object o1, Object o2)
//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())); } }