博客
关于我
Day79.Java8的其他新特性复习 -Java8其他新特性
阅读量:341 次
发布时间:2019-03-04

本文共 1965 字,大约阅读时间需要 6 分钟。

Java8?????

Lambda???

Lambda????????????????????????????????Lambda??????????????

Lambda????????

  • ????

    Lambda??????????(????) -> Lambda?
    ???->??lambda????

  • ???????

    • ????????????????????->?
    • ?????????????????????????->?
    • ????????????????????
  • Lambda????

    • ??Lambda????????????{}?????->???
    • ?????????????{}???
  • Lambda????????

  • ?????

    Java8??????????????Runnable?Comparator?Function?BiFunction??????????Lambda??????

  • ????

    Method Reference?????Lambda?????????????????????????

  • ????

    Method Reference???????????????????????????????Lambda???????

    Method Reference???

  • ??????

    ????::???
    ???PrintStream ps = System.out; Consumer<String> con2 = ps::println;

  • ?????

    ??::???
    ???Comparator<Integer> com2 = Integer::compare;

  • ?????

    ??::new
    ???Supplier<Employee> sup2 = Employee::new;

  • Method Reference?????

  • ?????????

    ??????????????????????????????Method Reference?

  • ???????

    Method Reference??????????????Lambda????

  • Stream API

    Stream API?Java8?????????????????????????????????

    Stream?????

  • ????

    employees.stream() ? employees.parallelStream()?

  • ????

    Arrays.stream(int[] array)?

  • ??Stream.of()

    Stream.of(1,2,3,4)?

  • ?????

    Stream.iterate() ? Stream.generate()?

  • Stream?????

  • ?????

    • filter(Predicate p)??????
    • limit(n)????????
    • skip(n)??????
    • distinct()????
  • ??

    • map(Function f)??????
    • flatMap(Function f)??????
  • ??

    • sorted()??????
    • sorted(Comparator c)??????
  • Stream?????

  • ?????

    • allMatch(Predicate p)??????????
    • anyMatch(Predicate p)????????????
    • noneMatch(Predicate p)??????????
    • findFirst()?????????
    • findAny()??????????
  • ??

    • reduce(T identity, BinaryOperator b)????????????
  • ??

    • collect(Collector c)????????????????
  • Optional????

    Optional???????????????????????

    ??Optional??

  • Optional.of(T t)??????Optional???
  • Optional.empty()?????Optional???
  • Optional.ofNullable(T t)?????null?Optional???
  • ????

  • orElse(T t)???Optional??????????????
  • get()???Optional???????????????
  • ??

    Optional
    employeeOptional = Optional.ofNullable(boy);Employee employee = employeeOptional.orElse(new Employee("??"));

    ??Optional??????????????????????????

    转载地址:http://ifoq.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现even_tree偶数树算法(附完整源码)
    查看>>
    Objective-C实现Exceeding words超词(差距是ascii码的距离) 算法(附完整源码)
    查看>>
    Objective-C实现exchange sort交换排序算法(附完整源码)
    查看>>
    Objective-C实现ExponentialSearch指数搜索算法(附完整源码)
    查看>>
    Objective-C实现extended euclidean algorithm扩展欧几里得算法(附完整源码)
    查看>>
    Objective-C实现ExtendedEuclidean扩展欧几里德GCD算法(附完整源码)
    查看>>
    Objective-C实现external sort外排序算法(附完整源码)
    查看>>
    Objective-C实现Factorial digit sum阶乘数字和算法(附完整源码)
    查看>>
    Objective-C实现factorial iterative阶乘迭代算法(附完整源码)
    查看>>
    Objective-C实现factorial recursive阶乘递归算法(附完整源码)
    查看>>
    Objective-C实现factorial阶乘算法(附完整源码)
    查看>>
    Objective-C实现Farey Approximation近似算法(附完整源码)
    查看>>
    Objective-C实现Fast Powering算法(附完整源码)
    查看>>
    Objective-C实现Fedwick树算法(附完整源码)
    查看>>
    Objective-C实现fenwick tree芬威克树算法(附完整源码)
    查看>>
    Objective-C实现FenwickTree芬威克树算法(附完整源码)
    查看>>
    Objective-C实现fermat little theorem费马小定理算法(附完整源码)
    查看>>
    Objective-C实现FermatPrimalityTest费马素数测试算法(附完整源码)
    查看>>
    Objective-C实现fft2函数功能(附完整源码)
    查看>>
    Objective-C实现FFT快速傅立叶变换算法(附完整源码)
    查看>>