Java Array Duplicate isDuplicated(String[] strArray)

Here you can find the source of isDuplicated(String[] strArray)

Description

Check if there are duplicated values in a string array

License

Apache License

Parameter

Parameter Description
strArray a parameter

Declaration

public static boolean isDuplicated(String[] strArray) 

Method Source Code

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

import java.util.*;

public class Main {
    /**//w ww . j  a v a2  s.  c  o m
     * Check if there are duplicated values in a string array
     *
     * @param strArray
     * @return
     */
    public static boolean isDuplicated(String[] strArray) {
        Set<String> strSet = new HashSet<String>();

        for (int i = 0; i < strArray.length; i++) {
            strSet.add(strArray[i]);
        }

        return (strSet.size() < strArray.length) ? true : false;
    }
}

Related

  1. arrayDuplicate(byte[] in)
  2. deleteDuplicatedPages(int[] pages)
  3. duplicateArrayEntries(String[] inputArr, int numDuplicates)
  4. eraseDuplicatedValue(String[] srcArr)
  5. hasDuplicates(final T[] array)
  6. removeDuplicates(double[] array)
  7. removeDuplicates(final Object[] array)
  8. removeDuplicates(int[] input)
  9. removeDuplicates(T[] elements)