Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Help Java S Java Set

Related Tutorials


 
 

Share on Google+Share on Google+

Java Set

Advertisement
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 

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 17, 2009

Related Tutorials

Discuss: Java Set  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com