Java Object Equal equals(Object object1, Object object2)

Here you can find the source of equals(Object object1, Object object2)

Description

equals

License

Open Source License

Declaration

static boolean equals(Object object1, Object object2) 

Method Source Code

//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;
    }
}

Related

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