If I have code that looks like this:
Collection<Object> c = new HashSet<Object>();
will it still retain the properties that the collection will not be able to contain duplicate values. In other words, what would happen in the following situation?
String h = "Hello World!";
c.add(h);
c.add(h);
Yes, the behavior and properties of
Setwill still hold.cwill only contain one instance of"Hello World!"The above
mainmethod outputs: