Find If A List Has Duplicates - Java Quiz Question


Write a program to find if a list has duplicates.

Input (Strings List) Output (Boolean - whether list has duplicates or not)
["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "May", "Jan"] true
["Jan", "Jan", "Jan", "Jan", "Jan", "Jan"] true
["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"] false
["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] false


import java.util.*;
class FindIfListHasDuplicates
{
    public static void main(String s[])
    {
        List<String> months = new ArrayList<String>();
        months.add("Jan");
        months.add("Feb");
        months.add("Mar");
        months.add("Apr");
        months.add("May");
        months.add("Jun");
        months.add("Jul");
        months.add("May");
        months.add("Feb");
        
        boolean result = hasDuplicates(months);
        
        if(result)
        {
            System.out.println("The list " + months + " has duplicates.");
        }
        else
        {
            System.out.println("The list " + months + " has no duplicates.");
        }

    }


    public static boolean hasDuplicates(List<String> inputList)
    {
    }

}