Java Array Equal isEquals(Object firstArray, Object secondArray)

Here you can find the source of isEquals(Object firstArray, Object secondArray)

Description

is Equals

License

Apache License

Declaration

public static boolean isEquals(Object firstArray, Object secondArray) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    public static boolean isEquals(Object firstArray, Object secondArray) {
        if (firstArray.getClass() != secondArray.getClass()) {
            return false;
        }/*w  w  w  .  j  a v a 2  s  .c  o m*/
        Class arrayClass = firstArray.getClass();

        if (boolean[].class.equals(arrayClass)) {
            return Arrays.equals((boolean[]) firstArray, (boolean[]) secondArray);
        } else if (byte[].class.equals(arrayClass)) {
            return Arrays.equals((byte[]) firstArray, (byte[]) secondArray);
        } else if (short[].class.equals(arrayClass)) {
            return Arrays.equals((short[]) firstArray, (short[]) secondArray);
        } else if (int[].class.equals(arrayClass)) {
            return Arrays.equals((int[]) firstArray, (int[]) secondArray);
        } else if (long[].class.equals(arrayClass)) {
            return Arrays.equals((long[]) firstArray, (long[]) secondArray);
        } else if (float[].class.equals(arrayClass)) {
            return Arrays.equals((float[]) firstArray, (float[]) secondArray);
        } else if (double[].class.equals(arrayClass)) {
            return Arrays.equals((double[]) firstArray, (double[]) secondArray);
        } else if (char[].class.equals(arrayClass)) {
            return Arrays.equals((char[]) firstArray, (char[]) secondArray);
        } else {
            return Arrays.equals((Object[]) firstArray, (Object[]) secondArray);
        }
    }
}

Related

  1. equalStringArrays(String[] expected, String[] actual)
  2. findMinimaGreaterOrEqual(final int[] min, final int elt)
  3. getClosestIndexEqualToOrLargerThanGivenCoordinate(double[] coordinates, double coordinate)
  4. isEquals(byte[] id1, byte[] id2)
  5. isEquals(char[] o1, char[] o2)
  6. safeEquals(final byte[] obj1, final byte[] obj2)