TreeSet: first() : TreeSet « java.util « Java by API






TreeSet: first()

  

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

public class Main {
  public static void main(String args[]) throws Exception {
    String elements[] = { "A", "C", "D", "G", "F" };
    TreeSet<String> set = new TreeSet<String>(Arrays.asList(elements));
    System.out.println(set);
    System.out.println(set.first());
    System.out.println(set.last());
  }
}

   
    
  








Related examples in the same category

1.new TreeSet < E > ()
2.new TreeSet(Collection c)
3.new TreeSet < E > (Comparator < ? super E > c)
4.TreeSet: add(E o)
5.TreeSet: comparator()
6.TreeSet: headSet(T toElement)
7.TreeSet: last()
8.TreeSet: remove(Object o)
9.TreeSet: subSet(T fromElement, T toElement)
10.TreeSet: tailSet(T fromElement)