遍历List集合可以使用for循环或者foreach循环。

使用for循环遍历集合:

List<NoticeLog> all = noticeLogService.getAll();
for (int i = 0; i < all.size(); i++) {
    NoticeLog noticeLog = all.get(i);
    // 执行相应的操作
}

使用foreach循环遍历集合:

List<NoticeLog> all = noticeLogService.getAll();
for (NoticeLog noticeLog : all) {
    // 执行相应的操作
}
遍历这个集合 ListNoticeLog all = noticeLogServicegetAll;

原文地址: https://www.cveoy.top/t/topic/i9sR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录