• jdk 1.8 新特性


    @Test
    public void testList() {
    ArrayList<Integer> arrayList = new ArrayList<>();
    arrayList.add(11);
    arrayList.add(22);
    arrayList.add(33);
    arrayList.add(44);
    arrayList.add(11);
    System.out.println("arrayList:" + arrayList);
    arrayList.stream().forEach(x -> {
    System.out.println("foreach:" + x);
    });
    System.out.println("------------------ filter ------------------------------");
    List<Integer> c = arrayList.stream().filter(x -> x.equals(33)).collect(Collectors.toList());
    System.out.println("filter:" + c);
    System.out.println("------------------ distinct ------------------------------");
    List<Integer> collect = arrayList.stream().distinct().collect(Collectors.toList());
    System.out.println("distinct:" + collect);
    System.out.println("------------------ limit ------------------------------");
    List<Integer> collect1 = arrayList.stream().limit(3).collect(Collectors.toList());
    System.out.println("limit:" + collect1);
    System.out.println("------------------ min ------------------------------");
    int minValue = arrayList.stream().min(Comparator.comparing(Integer::intValue)).get().intValue();
    System.out.println("max:" + minValue);
    System.out.println("------------------ max ------------------------------");
    int maxValue = arrayList.stream().max(Comparator.comparing(Integer::intValue)).get().intValue();
    System.out.println("max:" + maxValue);
    }
  • 相关阅读:
    Xcode配置.pch文件
    iOS ViewController生命周期
    小技巧 -- 隐藏导航栏返回按钮附带的文字
    添加App启动页面
    iOS 关于nil和Nil及null与<null>的区别
    文件上传之组件
    js验证
    java mail
    validform 一款好用的表单验证插件
    tomcat启动时出错
  • 原文地址:https://www.cnblogs.com/ming-blogs/p/11903722.html
Copyright © 2020-2023  润新知