Skip to content
CodeKruPro

Adding a duplicate to a Set

Predict the outputEasyJava only
Main.java
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        System.out.println(set.add("a"));
        System.out.println(set.add("a"));
        System.out.println(set.size());
        System.out.println(set.contains("a"));
    }
}

Graded by exact match. Spaces at the ends of lines and blank lines at the end do not count.

to answer and keep your progress. Reading is free for everyone.