码迷,mamicode.com
首页 > 移动开发 > 详细

AppleWeightSortDemo

时间:2018-09-02 20:10:15      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:[]   each   .com   div   package   array   highlight   demo   system   

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

技术分享图片

AppleWeightSortDemo

标签:[]   each   .com   div   package   array   highlight   demo   system   

原文地址:https://www.cnblogs.com/i-hard-working/p/9574700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!