惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
SegmentFault 最新的问题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
F
Full Disclosure
Vercel News
Vercel News
N
News | PayPal Newsroom
The GitHub Blog
The GitHub Blog
H
Hacker News: Front Page
H
Heimdal Security Blog
P
Privacy International News Feed
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
L
Lohrmann on Cybersecurity
D
Docker
Recent Announcements
Recent Announcements
Security Archives - TechRepublic
Security Archives - TechRepublic
人人都是产品经理
人人都是产品经理
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
T
Tailwind CSS Blog
C
Check Point Blog
博客园 - 叶小钗
Google Online Security Blog
Google Online Security Blog
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
S
Secure Thoughts
博客园 - Franky
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
P
Palo Alto Networks Blog
Latest news
Latest news
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Last Week in AI
Last Week in AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cyberwarzone
Cyberwarzone
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Threatpost
T
Tenable Blog
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学

博客园 - happy刘艺

关于SKILL idea解压包安装问题解决 转:Git的使用--如何将本地项目上传到Github(两种简单、方便的方法) 转:springboot 与swagger整合出现Unable to infer base url.This is common when using dynamic的解决办法 转:Swagger2自动生成接口文档和Mock模拟数据 InfluxDB springboot application.properties文件加载顺序 maven surefire插件与testng spring-boot项目学习路径 collection 与stream与lambd表达式的结合使用 转:Java中Lambda表达式的使用 RPC之Thrift 介绍及java实例 class对象的getResource()方法 Eclipse开发,编译,打包常见问题总结------持续更新 mysql查找包含某个字符串的记录 性能测试入门(零)测试前言 性能测试入门(八)jmeter--PerfMon(性能监控工具)插件安装与部署 jmeter--PerfMon(性能监控工具)插件使用详解 性能测试入门(七)jmeter分布式测试
转载:java :: Java中的双冒号操作符
happy刘艺 · 2021-02-22 · via 博客园 - happy刘艺

转自:https://www.cnblogs.com/yanlong300/p/9209243.html

java中的双冒号操作符

定义

双冒号运算操作符是类方法的句柄,lambda表达式的一种简写,这种简写的学名叫eta-conversion或者叫η-conversion。

通常的情况下:

把 x -> System.out.println(x) 简化为 System.out::println 的过程称之为 eta-conversion

把 System.out::println 简化为 x -> System.out.println(x) 的过程称之为 eta-expansion

范式:
类名::方法名

注意:

  1. 方法后面并没有()
  2. 懒加载方法是否调用要看调用方使用情况

使用范例

方法调用

person -> person.getAge();
可以替换成
Person::getAge

x -> System.out.println(x)
可以替换成
System.out::println
out是一个PrintStream类的对象,println是该类的方法,依据x的类型来重载方法

创建对象

() -> new ArrayList<>();
可以替换为
ArrayList::new
new关键字实际上调用的是ArrayList的构造方法

JVM实现

JVM底层实现是CallSite,对JDK层暴漏的接口是Functional

引用

http://hongjiang.info/eta-conversion-and-eta-expansion/