AppleWeightSortDemo

package 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()));
    }
}

posted on 2018-09-02 18:35  shammgod_code  阅读(92)  评论(0编辑  收藏  举报

导航