How to iterate through an ArrayList of Objects of ArrayList of Objects?

前端 未结 6 622
温柔的废话
温柔的废话 2020-12-24 01:18

Using an example:

Let say I have a class call Gun. I have another class call Bullet.

Class Gun has an

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 01:36

    When using Java8 it would be more easier and a single liner only.

        gunList.get(2).getBullets().forEach(n -> System.out.println(n));
    

提交回复
热议问题