import java.util.*;public class SortedSetDemo {
public static void main(String[] args) {
SortedSet sortedSet = new TreeSet(Arrays.asList(
"one two three four five six seven eight".split(" ")));
System.out.println(sortedSet);


}}结果是[eight, five, four, one, seven, six, three, two]上面的没有重载comparator方法,请问是如何排序的

解决方案 »

  1.   

    交流群 C++ java 36414176
      

  2.   

    应该是这样没错,不过我想知道程序是怎么排序的,是继承父类里的comparator方法吗
      

  3.   

    你可以实现Comparator<T>接口,
      

  4.   

    String类本身应该实现了IComparable接口。
      

  5.   

    字母ASCII排序
    是的它默认实现了compareto接口。。
      

  6.   

    说错了,是Comparable。不是IComparable,跟C#搞混了。