Home Help Java S Java Set



Java Set
Posted on: November 17, 2009 at 12:00 AM
Collections are objects that hold other objects which are maintained under some set of rules.

Java Set

     

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:

  1. java.util.HashSet: This class is implemented with a hash table. Entries are unsorted and no guarantees for the iteration order. This class permits the null element.
  2. java.util.TreeSet: This class is implemented as a balanced binary tree. Entries are sorted. This implementation is not synchronized.

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 

 

Related Tags for Java Set:


More Tutorials from this section

Ask Questions?    Discuss: Java Set  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.