Lambda遍历Map集合


  1. 实体类
	@Data
	class Student01 {
		private Integer id;
		private String name;

		Student01(Integer id, String name) {
			this.id = id;
			this.name = name;
		}
	}
  1. 遍历Map集合
	Map<String, Student01> map = new HashMap<>();
	map.put("甲班", new Student01(1, "张三"));
	map.put("乙班", new Student01(2, "李四"));

	map.forEach((key, value) -> {
		if (!"甲班".equals(key)) {
			System.out.println(value);
		}
	});
	//TODO: Student01(id=2, name=李四)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM