当前位置:网站首页>lamda 获取当前循环数,AtomicInteger
lamda 获取当前循环数,AtomicInteger
2022-07-28 05:17:00 【wang0112233】
需求:获取对象数据赋值给新的对象,并给对象排序,因为可以在页面上变更顺序,所以需要存储下标进行排序
方法一:
public static void main(String[] args) {
List<NwWorkOrderFinish> list = new ArrayList<>();
list.add(new NwWorkOrderFinish(1, "1", "张三"));
list.add(new NwWorkOrderFinish(2, "1", "李四"));
list.add(new NwWorkOrderFinish(3, "1", "王五"));
Stream.iterate(1, i -> i + 1).limit(list.size()).forEach(index -> {
System.out.println(index);
});
}方法二:
使用原子类AtomicInteger
public static void main(String[] args) {
List<NwWorkOrderFinish> list = new ArrayList<>();
list.add(new NwWorkOrderFinish(1, false, "张三"));
list.add(new NwWorkOrderFinish(2, false, "李四"));
list.add(new NwWorkOrderFinish(3, false, "王五"));
AtomicInteger atomicInteger = new AtomicInteger(0);
list.stream().forEach(nwWorkOrderFinish -> {
atomicInteger.decrementAndGet();
System.out.println(atomicInteger.get());
});
}边栏推荐
- The default isolation level of MySQL is RR. Why does Alibaba and other large manufacturers change to RC?
- Struct模块到底有多实用?一个知识点立马学习
- 从微服务基本概念到核心组件-通过一个实例来讲解和分析
- The solution after the samesite by default cookies of Chrome browser 91 version are removed, and the solution that cross domain post requests in chrome cannot carry cookies
- Classes and objects [medium]
- Clickhouse pit filling note 2: the join condition does not support non equal judgments such as greater than and less than
- Keil Chinese garbled code solution
- DELL远程控制卡 使用ipmitools设置ipmi
- JSON in JS (launch object deep copy)
- 2022 summer practice (first week)
猜你喜欢
![[computer level 3 information security] overview of information security assurance](/img/f0/a72e61fda58ea93ca4e9db7274f6e3.png)
[computer level 3 information security] overview of information security assurance

【idea插件神器】教你如何使用IDEA一键set实体类中所有属性

【ARXIV2203】CMX: Cross-Modal Fusion for RGB-X Semantic Segmentation with Transformers

The most detailed installation of windows10 virtual machine, install virtual machine by hand, and solve the problem that the Hyper-V option cannot be found in the home version window

这种动态规划你见过吗——状态机动态规划之股票问题(中)

Reading notes of SMT practical guide 1

Invalid bound statement (not found): com.exam.mapper.UserMapper.findbyid

【ARXIV2205】EdgeViTs: Competing Light-weight CNNs on Mobile Devices with Vision Transformers

C language classic 100 question exercise (1~21)

【ARIXV2204】Neighborhood attention transformer
随机推荐
Anaconda common instructions
Printf function of input and output function in C language
Using RAC to realize the sending logic of verification code
Implementation of simple upload function in PHP development
【CVPR2022 oral】Balanced Multimodal Learning via On-the-fly Gradient Modulation
Share several methods of managing flag bits in C program
Tips for using swiper (1)
Class class added in ES6
MySQL practice 45 lectures
微服务故障模式与构建弹性系统
Dcgan:deep volume general adaptive networks -- paper analysis
11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc
Online sql to XML tool
ArrayList多线程安全解决办法
2022 summer practice (first week)
list indices must be integers or slices, not tuple
ES6 new variable modifiers let and const, new basic data type symbol
【ARXIV2204】Vision Transformers for Single Image Dehazing
解决Oracle使用in语句不能超过1000问题
Duoyu security browser will improve the security mode and make users browse more safely