Write a method called markLength4 that accepts an ArrayList of strings as a parameter and that places a string of four asterisks "****" in front of every string of length 4. For example, suppose that a variable called list contains the values [“this”, “is”, “lots”, “of”, “fun”, “for”, “Java”, “coders”]. The call of markLength4(list); should change the list to store the values [“****”, “this”, “is”, “****”, “lots”, “of”, “fun”, “for”, “****”, “Java”, “coders”].
public static void markLength4(ArrayList strList)
{
for(int i = 0; i < strList.size(); i++)
{
if(strList.get(i).length() == 4)
{
strList.add(i, "****");
i++;
}
}
}