我有 -
import java.util.*;
public class TestCompare {
List<String> list = Arrays.asList("10", "1", "20", "11", "21", "12");
Comparator<String> cmp = new Comparator<String>() {
public int compare(String o1, String o2) {
return Integer.valueOf(o1).compareTo(Integer.valueOf(o2));
}
};
Collections.sort(list, cmp);
}
在Collections.sort(list, cmp);
有一个错误 - Syntax error on token "(", delete this token
。这种语法有什么问题?