why?
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> strings = new ArrayList<String>();
strings.add("Sam");
strings.add("I");
strings.add("Am");
for(int i=0;i<strings.size();i++){
if(i==strings.size()-1)
strings.add("Ham");
else
strings.add(i+1,"Ham");
}
for(String str : strings){
System.out.println(str);
}
}
}