What is the TreeSet class?

November 25th, 2006 by uCertify Leave a reply »

The TreeSet class extends the AbstractSet class. It implements the SortedSet, Cloneable, and Serializable interfaces. It also implements the Set interface, backed by a TreeMap instance. This class guarantees that the sorted set will be in ascending element order, sorted according to the natural order of the elements, or by the comparator provided at set creation time, depending on which constructor is used. The following are the constructors of TreeSet:

TreeSet()
TreeSet(Collection c)
TreeSet(Comparator c)
TreeSet(SortedSet s)

The elements that are going to be inserted into the TreeSet must implement the Comparable interface. If a user attempts to add an element to the set that violates this constraint, the add(Object) call will throw a ClassCastException.

Download free practice test for scjp-5-0 SCJP 5/6 exam. Download free practice test for CX310-065 SCJP 6.0 exam.
Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.