List<String> stringList = new ArrayList<>();
stringList.add("张三");
stringList.add("李四");
stringList.add("张二马总");
stringList.add("李白的");
stringList.add("杜甫");
List<String> collect = stringList.stream().sorted(Comparator.comparingInt(String::length).reversed()).collect(Collectors.toList());
System.out.println("collect = " + collect.toString());
Java 字符串List集合按照字符串长度排序(Stream流)
最新推荐文章于 2026-08-10 16:08:19 发布

6115

被折叠的 条评论
为什么被折叠?



