Write a method called doubleList that takes an ArrayList of String s as a parameter and replaces every String with two of that same String . For example, if the list stores the values (“how”, “are”, “you?”) before the method is called, it should store the values (“how”, “how”, “are”, “are”, “you?”, “you?”) after the method finishes executing.
public static void doubleList(ArrayList strList)
{
for(int i = 0; i < strList.size(); i += 2)
{
String str = strList.get(i);
strList.add(i + 1, str);
}
}