How to print an Array List on multiple lines?

后端 未结 3 890
慢半拍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条回答
  •  渐次进展
    2021-01-22 05:33

    Just iterate over the list and print each item seperately:

      public void printMeals() {
        for(String meal : meals) {
            System.out.println(meal);
        }
      }
    

提交回复
热议问题