java Set interface TreeSet

HashSet bottom is achieved, it is possible to implement sorting

    Set<Integer> set =new TreeSet<>();
    set.add(200);
    set.add(600);
    set.add(100);
    for(Integer i :set)
    {
        System.out.println(i);  //递增排序
    }

To implement a custom class sorting required to achieve comparable <> interfaces and the compareTo (...) abstract method

Guess you like

Origin blog.51cto.com/14437184/2422110