I do have the string "Ham" after each word, on a new line. This is my output:
Sam
Ham
I
Ham
Am
Ham
I don't understand why the condition "After each word, add the string "Ham" to the list" isn't passing, can someone explain this to me please?
package com.codegym.task.task07.task0715;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
More Sam-I-Am
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> list = new ArrayList<>();
list.add("Sam");
list.add("I");
list.add("Am");
for (String s : list){
System.out.println(s + "\nHam");
}
}
}