Java Array Equal arrayEquals(Object[] array1, Object[] array2)

Here you can find the source of arrayEquals(Object[] array1, Object[] array2)

Description

array Equals

License

Apache License

Declaration

static boolean arrayEquals(Object[] array1, Object[] array2) 

Method Source Code

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

public class Main {
    static boolean arrayEquals(Object[] array1, Object[] array2) {
        if (array1.length != array2.length) {
            return false;
        }//from  ww w  . ja  va2 s .  c o m
        for (int i = 0; i < array1.length; i++) {
            if (!equals(array1[i], array2[i])) {
                return false;
            }
        }
        return true;
    }

    static boolean equals(Object o1, Object o2) {
        if (o1 == null && o2 == null) {
            return true;
        }
        if (o1 == null || o2 == null) {
            return false;
        }
        if (o1.getClass().isArray() && o2.getClass().isArray()) {
            return arrayEquals((Object[]) o1, (Object[]) o2);
        }
        return o1.equals(o2);
    }
}

Related

  1. arrayEquals(int[] a1, int[] a2)
  2. arrayEquals(int[] arr1, int[] arr2)
  3. arrayEquals(Object[] a, Object[] b)
  4. arrayEquals(Object[] a, Object[] b)
  5. arrayEquals(Object[] arr1, Object[] arr2)
  6. arrayEquals(Object[] source, Object target)
  7. arrayEquals(Object[] source, Object target)
  8. arrayEquals(String[] array1, String[] array2)
  9. arrayEquals(String[] targetMethodParamTypes, String[] paramTypes)