Write a method called stutter that accepts an ArrayList ofstrings and an integer k as parameters and that replaces everystring with k copies of that string. For example, if the liststores the values [“how”, “are”, “you?”] before the method iscalled and k is 4, it should store the values [“how”, “how”, “how”,”how”, “are”, “are”, “are”, “are”, “you?”, “you?”, “you?”, “you?”]after the method finishes executing. If k is 0 or negative, thelist should be empty after the call.
Solution
public void stutter(ArrayList<String> str, int k) { if(k <= 0) { str.clear();
OR
OR