当前位置:网站首页>Copy ‘XXXX‘ to effectively final temp variable
Copy ‘XXXX‘ to effectively final temp variable
2022-07-01 21:42:00 【小曲同学呀】
今天,在项目中使用lambda表达式遇到了一个问题:
Copy 'standDatasMap' to effectively final temp variable
翻译过来就是:xxxx使用有效的最终变量。
那什么意思呢?
大家先看一下,lambda表达式的规则:
- 只能引用标记了 final 的外层局部变量,这就是说不能在 lambda 内部修改定义在域外的局部变量,否则会编译错误。
- 局部变量可以不用声明为 final,但是必须不可被后面的代码修改(即隐性的具有 final 的语义)
- 不允许声明一个与局部变量同名的参数或者局部变量。
给大家写个例子,简单情景再现下:
原因:
这是因为lambda表达式不接受动态传参。
修改如下:

我们可以加一个map,用来接收动态参数,即可解决此问题。
边栏推荐
- 基于LSTM模型实现新闻分类
- A debugging to understand the slot mechanism of redis cluster
- CNN convolution neural network principle explanation + image recognition application (with source code) [easy to understand]
- AirServer2022最新版功能介绍及下载
- Using closures to switch toggle by clicking a button
- String类型转换BigDecimal、Date类型
- Separate the letters and numbers in the string so that the letters come first and the array comes last
- "The silk road is in its youth and looks at Fujian" is in the hot collection of works in the Fujian foreign youth short video competition
- pytest合集(2)— pytest运行方式
- Burpsuite simple packet capturing tutorial [easy to understand]
猜你喜欢
随机推荐
【MySQL】索引的创建、查看和删除
Getting started with the lockust series
Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
Wechat applet, continuously playing multiple videos. Synthesize the appearance of a video and customize the video progress bar
js数组拼接的四种方法[通俗易懂]
Interview question: what is the difference between MySQL's Union all and union, and how many join methods MySQL has (Alibaba interview question) [easy to understand]
What is the difference between consonants and Initials? (difference between initials and consonants)
基于YOLOv5的口罩佩戴检测方法
Using closures to switch toggle by clicking a button
分离字符串中的字母和数字并使得字母在前数组在后
基于K-means的用户画像聚类模型
杰理之关于长按开机检测抬起问题【篇】
php反射型xss,反射型XSS测试及修复
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
Show member variables and methods in classes in idea
最近公共祖先离线做法(tarjan)
Business visualization - make your flowchart'run'up
News classification based on LSTM model
GaussDB(DWS)主动预防排查
杰理之、产线装配环节【篇】


![比较版本号[双指针截取自己想要的字串]](/img/19/4f858ffdc1281d6b8b18a996467f10.png)






