SortedSet: tailSet(E fromElement) : SortedSet « java.util « Java by API






SortedSet: tailSet(E fromElement)

 
/*
 Output:

[I, P]
[E, G]
[E, G, I]
[P]
[I, P]
[I]
[]
 * */

import java.util.Arrays;
import java.util.SortedSet;
import java.util.TreeSet;

public class MainClass {
  public static void main(String args[]) throws Exception {
    String elements[] = { "I", "P", "E", "G", "P" };
    SortedSet set = new TreeSet(Arrays.asList(elements));
    System.out.println(set.tailSet("I"));
    System.out.println(set.headSet("I"));
    System.out.println(set.headSet("I\0"));
    System.out.println(set.tailSet("I\0"));
    System.out.println(set.subSet("I", "P\0"));
    System.out.println(set.subSet("I", "I\0"));
    System.out.println(set.subSet("I", "I"));
  }
}
           
         
  








Related examples in the same category

1.SortedSet: add(String e)
2.SortedSet: headSet(E toElement)
3.SortedSet: iterator()
4.SortedSet: subSet(E fromElement, E toElement)