Java Object Equal equals(Object a, Object b)

Here you can find the source of equals(Object a, Object b)

Description

equals

License

Open Source License

Declaration

@SuppressWarnings({ "SimplifiableIfStatement", "BooleanMethodIsAlwaysInverted" })
    public static boolean equals(Object a, Object b) 

Method Source Code

//package com.java2s;
/*//w  ww. ja  v  a 2 s  .com
 * This file is part of Herschel Common Science System (HCSS).
 * Copyright 2001-2010 Herschel Science Ground Segment Consortium
 *
 * HCSS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * HCSS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with HCSS.
 * If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Arrays;

public class Main {
    @SuppressWarnings({ "SimplifiableIfStatement", "BooleanMethodIsAlwaysInverted" })
    public static boolean equals(Object a, Object b) {
        if (a instanceof double[] && b instanceof double[]) {
            return Arrays.equals((double[]) a, (double[]) b);
        }
        if (a instanceof float[] && b instanceof float[]) {
            return Arrays.equals((float[]) a, (float[]) b);
        }
        if (a instanceof long[] && b instanceof long[]) {
            return Arrays.equals((long[]) a, (long[]) b);
        }
        if (a instanceof int[] && b instanceof int[]) {
            return Arrays.equals((int[]) a, (int[]) b);
        }
        if (a instanceof short[] && b instanceof short[]) {
            return Arrays.equals((short[]) a, (short[]) b);
        }
        if (a instanceof byte[] && b instanceof byte[]) {
            return Arrays.equals((byte[]) a, (byte[]) b);
        }
        if (a instanceof boolean[] && b instanceof boolean[]) {
            return Arrays.equals((boolean[]) a, (boolean[]) b);
        }
        return false;
    }
}

Related

  1. areEqualStr(Object o1, Object o2)
  2. deepEquals(Object o1, Object o2)
  3. equalObjects(Object object1, Object object2)
  4. equals(BSONObject a, BSONObject b)
  5. equals(final Object a, final Object b)
  6. Equals(Object in1, Object in2)
  7. equals(Object o1, Object o2)
  8. equals(Object o1, Object o2)
  9. equals(Object o1, Object o2)