File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes TreeSet and it's interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "TreeSet and it Watch "TreeSet and it New topic

TreeSet and it's interface

Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
I'm reviewing collections, and of all the books I've read and other web-sites I come across all seem to indicate that the TreeSet implements the SortSet interface.
While looking through JDK I came across this:
"This class (java.util.TreeSet) implements the Set interface, backed by a TreeMap instance. ... "
It this an error in the jdk doc? Can someone explain the anomalies here?

<a href="" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Actually it is backed by a SortedMap
From the source:

[Blog] [Blogroll] [My Reviews] My Linked In
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Great work Valetin, I guess the source code can't lie ... the ultimate reference
So if I come across a ture/false type exam question asking if a TreeSet implements the SortSet interface I should answer false!
[ February 28, 2002: Message edited by: Rajinder Yadav ]
swapna sivaraju
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
Yeah i also came across this confusing statement..
can anyone elaborate on this.....
what does this mean--"-backed by TreeMap instance"..

I agree. Here's the link:
subject: TreeSet and it's interface
jQuery in Action, 3rd edition