lambda遍历list对象

lambda表达式 专栏收录该内容
8 篇文章 0 订阅

@Data
public class SchoolBoy {
	private String girlId;
	
	private String id;
	
	private String name;
 
	private String grilName;
}
    public static void main(String[] args) {
        List<SchoolBoy> schoolBoys = new ArrayList<>();
        SchoolBoy boy1 = new SchoolBoy();
        boy1.setGirlId("1");
        boy1.setId("10");
        boy1.setName("小明");

        SchoolBoy boy2 = new SchoolBoy();
        boy2.setGirlId("2");
        boy2.setId("11");
        boy2.setName("小豪");

        SchoolBoy boy3 = new SchoolBoy();
        boy3.setGirlId("3");
        boy3.setId("12");
        boy3.setName("小白");
        schoolBoys.add(boy1);
        schoolBoys.add(boy2);
        schoolBoys.add(boy3);

        schoolBoys.stream().forEach(schoolBoy -> {
            System.out.println(schoolBoy);
        });
    }

 

 

  • 0
    点赞
  • 1
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值