import java.util.*;

class Main {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 8, 4, 3, 2, 2, 4, 6, 1, 7, 1);
        HashMap<Integer, Boolean> s = new HashMap<>();
        
        list.stream().forEach(x -> {
            Boolean b = s.get(x);
            if (b == null) {
                s.put(x, false);
            } else if (b == false) {
                s.put(x, true);
                System.out.println(x);
            }
        });
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: