You could, however, have a collection object that contains objects of type String , Integer , and Double if it makes sense in your application. The Collection classes available to use in programs implement Collection interfaces. Interfaces are abstract data types that let collections be manipulated independently of their representation details. This lesson focuses on the List and Set collections. Set implementations do not permit duplicate elements, but List implementations do.
Duplicate elements have the same data type and value.
The API provides two general-purpose Set implementations. HashSet , which stores its elements in a hash table, and TreeSet , which stores its elements in a balanced binary tree called a red-black tree. The example for this lesson uses the HashSet implementation because it currently has the best performance. This diagram shows the Collection interfaces on the right and the class hierarchy for the java.util.HashSet on the left. You can see that the HashSet class implements the Set interface.