
Java8
积跬步DEV
一枚开发工程师!
展开
-
Java8 四大核心函数式接口 Function、Consumer、Supplier、Predicate使用示例
定义函数示例:Supplier supplier= () -> 100;定义函数示例:Consumer consumer= p -> System.out.println§;// 因为没有出参,常用于打印、发送短信等消费动作。定义函数示例:Predicate predicate = p -> p % 2 == 0;调用方法:boolean test(T t);调用方法:void accept(T t);调用方法:R apply(T t);T:入参类型,R:出参类型。调用方法:T get();原创 2023-06-15 08:53:29 · 651 阅读 · 0 评论 -
Java 8th 新特性:lambda表达式
今天看到别的人代码 private Runnable autoPageRunnable; autoPageRunnable = this::nextPage; private void nextPage() { runOnUiThread(() -> { screenOffTimerStart(); if (mPageLoader != nul...转载 2019-10-11 15:55:13 · 212 阅读 · 0 评论