Collections are objects that hold other objects which are maintained under some set of rules. A set is a public interface that extends the collection interface and comes under the collection framework It holds unique values means set does not contain duplicate elements. Collection interface is at the top of collection hierarchy and Set interface in "java.util" package is it's sub-class. It has two useful concrete classes that implements sets:
Note: Great care must be exercised while mutable objects are stored in the set. The behavior of a set is not predictable while an object is changed in a manner that affects equals comparisons while the object is an element in the set. For this a special case is that a set does not allow to contain itself as an element.
Learn more on the set interface at:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: November 17, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles