Here you can find the source of equals(Object object1, Object object2)
static boolean equals(Object object1, Object object2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2002, 2015 Innoopract Informationssysteme GmbH and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://ww w. j av a 2 s. c o m * Innoopract Informationssysteme GmbH - initial API and implementation * EclipseSource - ongoing development ******************************************************************************/ import java.util.Arrays; public class Main { static boolean equals(Object object1, Object object2) { boolean result; if (object1 == object2) { result = true; } else if (object1 == null) { result = false; } else if (object1 instanceof boolean[] && object2 instanceof boolean[]) { result = Arrays.equals((boolean[]) object1, (boolean[]) object2); } else if (object1 instanceof int[] && object2 instanceof int[]) { result = Arrays.equals((int[]) object1, (int[]) object2); } else if (object1 instanceof long[] && object2 instanceof long[]) { result = Arrays.equals((long[]) object1, (long[]) object2); } else if (object1 instanceof float[] && object2 instanceof float[]) { result = Arrays.equals((float[]) object1, (float[]) object2); } else if (object1 instanceof double[] && object2 instanceof double[]) { result = Arrays.equals((double[]) object1, (double[]) object2); } else if (object1 instanceof Object[] && object2 instanceof Object[]) { result = Arrays.equals((Object[]) object1, (Object[]) object2); } else { result = object1.equals(object2); } return result; } }