How to print an Array List on multiple lines?

后端 未结 3 867
慢半拍i
慢半拍i 2021-01-22 05:16

I\'m doing the MOOC java course, and I\'m stuck on exercise 76. Whenever I submit the answer it tells me to print each meal to a seperate line. How would I go about doing this?<

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 05:47

    In Java 8

    public void printMeals() {
        this.meals.stream().forEach(System.out::println);
    }
    

提交回复
热议问题