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流)
最新推荐文章于 2024-07-27 04:49:15 发布