Java Array Equal equals(Collection asCollection, String[] values)

Here you can find the source of equals(Collection asCollection, String[] values)

Description

Compare a collection of strings to an array of strings.

License

Open Source License

Declaration

public static boolean equals(Collection<String> asCollection, String[] values) 

Method Source Code

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

import java.util.Arrays;
import java.util.Collection;

import java.util.List;

public class Main {
    /**//w  w w  .j a  v  a2s  . c om
     * Compare a collection of strings to an array of strings.
     */
    public static boolean equals(Collection<String> asCollection, String[] values) {
        final List<String> asList = Arrays.asList(values);
        final boolean containsAll = asCollection.containsAll(asList);
        final int size = asCollection.size();
        final int length = values.length;
        return containsAll && length == size;
    }
}

Related

  1. equals(byte[] first, byte[] second)
  2. equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
  3. equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
  4. equals(char[] str1, char[] str2)
  5. equals(char[][] c1, char[][] c2)
  6. equals(double[][] xs, double[][] ys)
  7. equals(final byte[] a, final byte[] b)
  8. equals(final byte[] array1, final byte[] array2)
  9. equals(final T[][] a, final T[][] b)