Assume the availability of an instance variable arr that refers to an ArrayList of Strings. Write a helper method concatAll that returns the concatenation of all the Strings in the ArrayList in the order in which they appear in the ArrayList

Respuesta :

Answer:

Explanation:

The following code is written in Java and is a method that takes in an ArrayList as a parameter, it then loops through the ArrayList and adds each element to the instance variable called arr as well as a space between each element (this can be removed by deleting the " "). Finally, it prints the final result of the variable arr to the screen.

public static void concatAll(ArrayList<String> myArr) {

       String arr = "";

       for (int x = 0; x < myArr.size(); x++) {

           arr += myArr.get(x) + " ";

       }

       System.out.println(arr);

   }