Create TreeSet from String array : NavigableSet « Collections « Java Tutorial






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

public class CityNavigator {
  static NavigableSet<String> citiesSet;

  public static void main(String[] args) {
    String[] cities = { "A", "B", "C", "D", "E", "F" };

    citiesSet = new TreeSet<String>();
    for (String city : cities)
      citiesSet.add(city);

  }

}








9.23.NavigableSet
9.23.1.The NavigableSet Interface
9.23.2.Create TreeSet from String array
9.23.3.For each loop with generic NavigableSet, created from TreeSet
9.23.4.NavigableSet by TreeSet
9.23.5.NavigableSet.ceiling
9.23.6.NavigableSet.floor
9.23.7.NavigableSet.higher
9.23.8.NavigableSet.lower