set 排序实例

时间:2020-07-21 21:51:03   收藏:0   阅读:75
 public static void main( String[] args ) {
        Set<String> set = new HashSet<>();
        set.add("20180102");
        set.add("20180101");
        set.add("20180103");
        set.add("20180104");
        set.add("20180105");
        set.add("20180102");
        set.stream().sorted(Comparator.reverseOrder());
        System.out.println(set.toString());
        List<String> list=new ArrayList<>(set);
        String newKey=list.get(list.size()-1);
        System.out.println(newKey);

    }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!