Given:
import java.util.Collections; import java.util.TreeSet; public class Main { public static void main(String[] args) { TreeSet<String> s = new TreeSet<String>(); s.add("a"); s.add("f"); s.add("b"); System.out.print(s + " "); Collections.reverse(s);// w w w .ja va2 s. co m System.out.println(s); } }
What is the result?
A is correct.
The Collections methods sort()
, reverse()
, and binarySearch()
do not work on Sets.