Add values to TreeSet in Java
Description
The following code shows how to add values to TreeSet.
Example
/*from ww w. ja va 2 s . c o m*/
import java.util.TreeSet;
public class Main {
public static void main(String args[]) {
TreeSet<String> ts = new TreeSet<String>();
ts.add("C");
ts.add("A");
ts.add("B");
ts.add("E");
ts.add("F");
ts.add("java2s.com");
System.out.println(ts);
}
}
The code above generates the following result.