当前位置:网站首页>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());
});
}边栏推荐
- 【内功心法】——函数栈帧的创建和销毁(C实现)
- regular expression
- Flask Development & get/post request
- Invalid bound statement (not found): com.exam.mapper.UserMapper.findbyid
- I've been in an outsourcing company for two years, and I feel like I'm going to die
- [slam] lvi-sam analysis - Overview
- 使用nfpm制作rpm包
- SimpleDateFormat线程不安全和DateTimeFormatter线程安全
- 【ARXIV2205】Inception Transformer
- Implementation of simple upload function in PHP development
猜你喜欢

Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)

Configuration experiment of building virtual private network based on MPLS

Message forwarding mechanism -- save your program from crashing

11. < tag dynamic programming and subsequence, subarray> lt.115. Different subsequences + Lt. 583. Deletion of two strings DBC

21 day SQL punch in summary

多御安全浏览器将改进安全模式,让用户浏览更安全

使用navicat或plsql导出csv格式,超过15位数字后面变成000(E+19)的问题

为什么md5不可逆,却还可能被md5免费解密网站解密

Keil Chinese garbled code solution

Mysql基本查询
随机推荐
Invalid bound statement (not found): com.exam.mapper.UserMapper.findbyid
First acquaintance with C language (2)
Internal implementation principle of yymodel
Making RPM packages with nfpm
【ARIXV2204】Neighborhood attention transformer
使用nfpm制作rpm包
【ARXIV2203】SepViT: Separable Vision Transformer
Simulink automatically generates STM32 code details
regular expression
php7.1 连接sqlserver2008r2 如何测试成功
Tips for using swiper (1)
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
Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address
yandex robots txt
list indices must be integers or slices, not tuple
Mysql数据库索引(innodb引擎)
子父线程交互
Clickhouse pit filling note 2: the join condition does not support non equal judgments such as greater than and less than
block yandex bot
C language: realize the simple function of address book through structure