Java descendingSet method of navigableSet interface.

Java descendingSet method of navigableSet interface.


Posted in : Java Posted on : December 6, 2010 at 6:15 PM Comments : [ 0 ]

Java descendingSet method of navigableSet interface.

Java descendingSet method of navigableSet interface.

Here, we are going to introduce you to about the descendingSet() method of navigableSet. The descendingSet() is method of navigableSet interface in java. It returns elements of navigableSet in reverse order.

Code:

NavigableSetExample1.java

import java.util.Iterator;
import java.util.NavigableSet;
import java.util.TreeSet;

public class NavigableSetExample1 {
public static void main(String[] args) {
	NavigableSet obNavigableSet = new TreeSet();
	obNavigableSet.add(2);
	obNavigableSet.add(3);
	obNavigableSet.add(4);
	obNavigableSet.add(5);
	obNavigableSet.add(6);
	System.out.println("Backward traversing of navigableSet.");
	Iterator backword = obNavigableSet.descendingIterator();
	while (backword.hasNext()) {
		System.out.println(backword.next());
	   }
	}
}
Output:
Backward traversing of navigableSet.
6
5
4
3
2

Download this code.
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics