package com.ant.jdk8.com.ant.jdk8.chap01; import java.util.Arrays; import java.util.Comparator; import java.util.List; public class AppleWeightSortDemo { public static void main(String[] args) { List<Apple> apples = Arrays.asList(new Apple("green",2), new Apple("green",1),new Apple("red",3)); apples.sort(Comparator.comparing(Apple::getWeight)); apples.stream().forEach(apple-> System.out.println(apple.getWeight())); } }
相关文章
- 10-14AppleWeightSortDemo