zoukankan      html  css  js  c++  java
  • 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);
    }
  • 相关阅读:
    封装
    魔术方法类与有关面向对象的关键字
    JS基础
    轮播效果
    进度条效果
    2018年6月
    2018年5月
    Monte Carlo tree search 学习
    2018年4月
    pachi 学习
  • 原文地址:https://www.cnblogs.com/ming-blogs/p/11903722.html
Copyright © 2011-2022 走看看