当前位置:网站首页>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()//平均值
边栏推荐
- MySQL order by
- 2. play the chromatic harmonica
- numpy np tips: numpy数组的squeeze等处理
- Interview with Mo Tianlun | ivorysql wangzhibin - ivorysql, an Oracle compatible open source database based on PostgreSQL
- 2D 照片变身 3D 模型,来看英伟达的 AI 新“魔法”!
- "Comment positionner l'industrie" dans la planification industrielle locale / parc
- Development of trading system (IX) -- dark pool technology
- Acmstreamopen return value problem
- [harmony OS] [ark UI] basic ETS context operations
- 1. first knowledge of chromatic harmonica
猜你喜欢

练习:仿真模拟福彩双色球——中500w巨奖到底有多难?跑跑代码就晓得了。

1280_ C language to find the average value of two unsigned integer

【openwrt】推荐一个国内开发的openwrt的版本,iStoreOS简介,非常好用,主要是做了一些优化。解决了汉化的问题。

Vigilance against over range collection of privacy - ten mobile app violations

Cesium graphic annotation circle, square, polygon, ellipse, etc

Is opencv open source?

client-go gin的简单整合十-Update

《悉达多》:一生之书,可以时常反刍

9 necessary soft skills for program ape career development

Cesium loading display thermal diagram
随机推荐
PHP代码审计2—这些函数必知必会
地方/园区产业规划之 “ 如何进行产业定位 ”
Development of trading system (VII) -- Analysis of trading delay
Development of trading system (x) -- fix agreement
How to draw an industry investment map
Development of trading system (IX) -- dark pool technology
Siddhartha: the book of life can be regurgitated frequently
Qt编译数据库插件通用步骤说明
Zoran community
MySQL order by
Monitoring pancakeswap new token
2D 照片变身 3D 模型,来看英伟达的 AI 新“魔法”!
练习:仿真模拟福彩双色球——中500w巨奖到底有多难?跑跑代码就晓得了。
[rust contribution] implement Message Oriented Middleware (6) -client from zero
MySQL modifies and deletes tables in batches according to the table prefix
【LeetCode】148. Sort linked list
Upgrade cmake
Do you really need automated testing?
Crawler grabs the idea of reading on wechat
Development of trading system (II) -- market data