SortedSet: add(String e) : SortedSet « java.util « Java by API






SortedSet: add(String e)

  

import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
  public static void main(String[] argv) throws Exception {
    SortedSet<String> set = new TreeSet<String>();
    set.add("b");
    set.add("c");
    set.add("a");

    Iterator it = set.iterator();
    while (it.hasNext()) {
      Object element = it.next();
    }
    String[] array = (String[]) set.toArray(new String[set.size()]);
  }
}

   
    
  








Related examples in the same category

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