Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Arrays;

import java.util.HashSet;
import java.util.List;

import java.util.Set;

public class Main {
    /**
     * Function to check if duplication elements are present in array or not.
     * @param contacts array of string
     * @return true if duplication is present else return false.
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static boolean isDuplicatePresent(String[] contacts) {
        List inputList = Arrays.asList(contacts);
        Set inputSet = new HashSet(inputList);
        if (inputSet.size() < inputList.size())
            return true;
        return false;
    }
}