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:
http:/www.roseindia.net/java/java-tips/data/collections/sets/sets.shtml
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java Set
Post your Comment