Java Array Equal equals(String[] fullSet, String[] subSet)

Here you can find the source of equals(String[] fullSet, String[] subSet)

Description

equals

License

Open Source License

Declaration

public static boolean equals(String[] fullSet, String[] subSet) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;

import java.util.List;

public class Main {
    public static boolean equals(String[] fullSet, String[] subSet) {
        if (isEmpty(fullSet) && isEmpty(subSet)) {
            return true;
        }//from   w w w.  j a  va2 s .c o m

        if (length(fullSet) != length(subSet)) {
            return false;
        }

        List<String> fullList = Arrays.asList(fullSet);
        List<String> subList = Arrays.asList(subSet);
        return fullList.containsAll(subList) && subList.containsAll(fullList);
    }

    public static boolean isEmpty(String[] arg) {
        if (arg == null) {
            return true;
        }
        return arg.length == 0;
    }

    public static int length(String[] strs) {
        if (isEmpty(strs)) {
            return 0;
        }
        return strs.length;
    }
}

Related

  1. equals(Map map1, Map map2)
  2. equals(Object array1, Object array2)
  3. equals(Object array1, Object array2)
  4. equals(Object array1, Object array2)
  5. equals(Object[] objs1, Object[] objs2)
  6. equals(T[] array1, T[] array2)
  7. equals3(double[][][] arr1, double[][][] arr2)
  8. equalsAny(T element, T[] array)
  9. equalsIgnoreSequence(final T[] array1, final T[] array2)