wood burning stoves*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "TreeSet and it Watch "TreeSet and it New topic
Author

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="http://www.rajindery.com" 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
Sheriff

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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[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
Hi
Yeah i also came across this confusing statement..
can anyone elaborate on this.....
what does this mean--"-backed by TreeMap instance"..
Swapna


SCPJ2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TreeSet and it's interface
 
Similar Threads
HFE page 72
Vector
TreeSet
code
why treeset does not implement equals and hashcode