This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes navigable set and sorted set 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 "navigable set and sorted set" Watch "navigable set and sorted set" New topic

navigable set and sorted set

Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446

what is the difference between navigable set and sorted set?

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

Prasad Kharkar wrote:what is the difference between navigable set and sorted set?

please go through JAVA 6 API here ..

SortedSet<E> is the super interface of NavigableSet<E> and is a sub interface of Set<E>
or in other words, Iterable<E> -> Collection<E> -> Set <E> -> SortedSet<E> -> NavigableSet<E> -> TreeSet<E> is the inheritance tree.
TreeSet<E> implements NavigableSet<E>

SortedSet<E> ss = TreeSet<E> ts. headSet(E element) // This returns a SortedSet
where as
NavigableSet<E> ns = TreeSet<E> ts.headSet(E element, boolean b) // this returns a Navigable Set

this is same with tailSet() and subSet() which are in SCJP6 objectives!

hope this is clear

SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Karthik Shiraly

Joined: Apr 04, 2009
Posts: 874

Ah no, ignore my previous post. I got it quite wrong!
I agree. Here's the link:
subject: navigable set and sorted set
It's not a secret anymore!