java 8 String类型转Integer排序

public static void main(String[] args) {
List<String> list = Arrays.asList("1", "10", "2");

//正序排列
Collections.sort(list,Comparator.comparingInt(Integer::parseInt));

//直接输出数组
System.out.println(list);
System.out.println("----------------------------");

//遍历输出
list.forEach(System.out::println);
}
posted @ 2021-04-02 15:53  Ash灬  阅读(1534)  评论(0)    收藏  举报