Map does not allow duplicate keys of course but allows duplicate values. So I think the answer would be d)
. The collection that does not allow any duplicates is Set
. An example with HashSet
:
import java.util.HashSet;
public class Main {
public static void main(String[] args) {
HashSet<String> set = new HashSet<String>();
set.add("str1");
set.add("str2");
set.add("str3");
set.add("str4");
set.add("str1");
System.out.println(set); // ["str1", "str2", "str3". "str4"] "str1" is added only once
}
}