当前位置:网站首页>IntStream API介绍
IntStream API介绍
2022-06-25 03:54:00 【一天不写代码难受】
1 创建int类型数组
import java.util.stream.IntStream;
IntStream range = IntStream.range(0, 10);
2 boxed()
boxed之前一直都是mapToObject(Integer::vaueOf)
集合中的元素都是引用类型的,需要把基本数据类型装箱,才能转为list
IntStream.range(0,10).boxed().collect(Collectors.toList());
3 mapToDouble()
这三个方法除了对应返回三种指定类型的stream外其他使用方法和作用和map类似,相当于map方法的特例。
list.stream().mapToDouble(User::getAge).sum()//和
list.stream().mapToDouble(User::getAge).max()//最大
list.stream().mapToDouble(User::getAge).min()//最小
list.stream().mapToDouble(User::getAge).average()//平均值
边栏推荐
- Lecture record: new application of inertial navigation - inertial measurement
- MySQL order by
- How much do you know about the use value of WMS warehouse management system
- Work assessment of pharmaceutical polymer materials of Jilin University in March of the 22nd spring -00025
- PHP代码审计1—PHP.ini的那些事
- Numpy NP tips: squeeze and other processing of numpy arrays
- Understand (DI) dependency injection in PHP
- "Comment positionner l'industrie" dans la planification industrielle locale / parc
- PHP code audit 2 - these functions must be known and understood
- [harmony OS] [ark UI] basic ETS context operations
猜你喜欢
Simple integration of client go gin 11 delete
Do you really need automated testing?
1280_C语言求两个无符号整形的平均值
Vigilance against over range collection of privacy - ten mobile app violations
How to draw an industry investment map
1.初识半音阶口琴
DAP data scheduling function improvement description
client-go gin的简单整合十一-Delete
2022-06-21-Flink-49(一. SQL手册)
Cesium 拖拽3D模型
随机推荐
Cesium drag 3D model
95% 程序员都在这里摸鱼……
1、项目第二阶段——用户注册和登陆
Where is the red area of OpenCV?
讲座记录《惯性导航的新应用——惯性测量》
Windows 2003 64 bit system PHP running error: 1% is not a valid Win32 Application
The 5th series of NFT works of missing parts was launched on the sandbox market platform
numpy np tips:使用opencv对数组插值放缩到固定形状 cv2.resize(res, dsize=(64, 64), interpolation=cv2.INTER_CUBIC)
Hello CTP (I) - basic knowledge of futures
web3.eth. Getpendingtransactions() returns null?
【openwrt】推荐一个国内开发的openwrt的版本,iStoreOS简介,非常好用,主要是做了一些优化。解决了汉化的问题。
Lecture record: history and development of strapdown inertial navigation solution
Lecture record: new application of inertial navigation - inertial measurement
讲座记录《捷联惯导解算的历史及发展》
numpy np tips: numpy数组的squeeze等处理
【LeetCode】143. 重排链表
Cesium loading display thermal diagram
BSC parsing input data of transaction
Uniapp makes mobile app programs, using uni Choosevideo record video, video playback is fuzzy, and the resolution is low
How to use crawlers to capture bullet screen and comment data of station B?