How to display the elements in descending order.
Previous | Home | Next |
This Example will shows how to Display the elements of TreeSet in Descending order.
Descending() is a method which is used to Display the elements of the TreeSet in descending order.
Descending() is a method which is used to Display the elements of the TreeSet in descending order.
With the help of object Tst call the descendingSet() method .
package Example;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.SortedSet;
public class TreeSetSubSet {
/**
* @param args
*/
public static void main(String[] args) {
TreeSet Tst =new TreeSet();
Tst.add(new Integer("10"));
Tst.add(new Integer("17"));
Tst.add(new Integer("15"));
Tst.add(new Integer("19"));
Tst.add(new Integer("12"));
Tst.add(new Integer("13"));
SortedSet sortedSet = Tst.descendingSet();
System.out.println("Elements of TreeSet in descending are : " + sortedSet);
// TODO Auto-generated method stub
}
}
Tail set Contains : [19, 17, 15, 13, 12, 10]
Previous | Home | Next |