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