How to find duplicate String in array List in java[User Input]

I am trying to write a code which will find the duplicate String in an user input arrayList. So, far I have written below code:

package – homework // public class- Assign2

package homework;
import static java.lang.reflect.Array.set;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
public class Assign2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(;
        List<String> name= new ArrayList<>();
        String s;
        int n;
        System.out.print("How many Name you want to check?-");
        for(int i=0;i<n;i++)
        Set<String> Set=new HashSet<>();
        Set<String> duplicatename = new HashSet<>();
        for (String xx : name)
        System.out.println("Duplicate Name:"+duplicatename);
Posted in Java Programming, ArrayListTags: