Java Utililty Methods Array Equal

List of utility methods to do Array Equal

Description

The list of methods to do Array Equal are organized into topic(s).

Method

booleanequals(Object array1, Object array2)
Determines if the given two arrays are equal, as determined by comparing their contents for equality.
Class<?> arrayType = array1.getClass();
if (!arrayType.isArray()) {
    throw new IllegalArgumentException("specified object is not an array");
Class<?> componentType = arrayType.getComponentType();
if (componentType.isPrimitive()) {
    if (componentType == boolean.class) {
        return array2 instanceof boolean[] && Arrays.equals((boolean[]) array1, (boolean[]) array2);
...
booleanequals(Object[] objs1, Object[] objs2)
equals
if ((objs1 == null) && (objs2 == null))
    return true;
if ((objs1 == null) || (objs2 == null))
    return false;
if (objs1.length != objs2.length)
    return false;
Set<Object> set1 = toSet(objs1);
Set<Object> set2 = toSet(objs2);
...
booleanequals(String[] fullSet, String[] subSet)
equals
if (isEmpty(fullSet) && isEmpty(subSet)) {
    return true;
if (length(fullSet) != length(subSet)) {
    return false;
List<String> fullList = Arrays.asList(fullSet);
List<String> subList = Arrays.asList(subSet);
...
booleanequals(T[] array1, T[] array2)
equals
if (array1.length != array2.length)
    return false;
int i, len = array1.length;
for (i = 0; i < len; i++) {
    if (!array1[i].equals(array2[i]))
        return false;
return true;
...
booleanequals3(double[][][] arr1, double[][][] arr2)
equals
int len1 = arr1.length;
if (len1 != arr2.length) {
    return false;
for (int i = 0; i < len1; i++) {
    if (!equals2(arr1[i], arr2[i])) {
        return false;
return true;
booleanequalsAny(T element, T[] array)
equalsAny compares a given element with all elements of a given array.
for (T e : array)
    if (e.equals(element))
        return true;
return false;
booleanequalsIgnoreSequence(final T[] array1, final T[] array2)
equals Ignore Sequence
if (array1 == null && array2 == null) {
    return true;
} else if (array1 == null || array2 == null) {
    return false;
if (array1.length != array2.length) {
    return false;
final T[] copyOfArray2 = Arrays.copyOf(array2, array2.length);
for (int i = 0; i < array1.length; i++) {
    final T o1 = array1[i];
    final int j = indexOf(copyOfArray2, o1, i);
    if (j == -1) {
        return false;
    if (i != j) {
        final T o2 = copyOfArray2[i];
        copyOfArray2[i] = array2[j];
        copyOfArray2[j] = o2;
return true;
booleanequalsIgnoreSequence(Object[] array1, Object[] array2)
equals Ignore Sequence
if ((array1 == null) && (array2 == null)) {
    return true;
} else if ((array1 == null) || (array2 == null)) {
    return false;
if (array1.length != array2.length) {
    return false;
List<Object> list = Arrays.asList(array2);
for (int i = 0; i < array1.length; i++) {
    Object o1 = array1[i];
    if (!list.contains(o1)) {
        return false;
return true;
booleanequalsToElement(final Object[] arr, final Object obj)
Checks if at least one array element equals the passed parameter.
if (arr == null) {
    if (obj == null) {
        return true;
    return false;
if (obj == null) {
    return false;
...
booleanequalStringArrays(String[] expected, String[] actual)
equal String Arrays
return Arrays.asList(expected).stream()
        .filter(expectedValue -> Arrays.asList(actual).stream().filter(expectedValue::equals).count() > 0)
        .count() == expected.length;