Question: Write a public static method named printArrayList, that takes two arguments. The first argument is an ArrayList of Integer and the second argument is a

Write a public static method named printArrayList, that takes two arguments. The first argument is an ArrayList of Integer and the second argument is a String. The method should print out a list of the values in the ArrayList, each separated by the value of the second argument.
For example, given an ArrayList of Integer named myList, that currently stores these values: {1,22,333,400,5005,9}
printArrayList(myArray,",") will print out 1,22,333,400,5005,9
printArrayList(myArray,"-") will print out 1-22-333-400-5005-9
You may wish to write some additional code to test your method.
Helpful Hints:
A loop will obviously be very useful here.
You do not want to print the separator string (second argument) after printing the last value in the array. Your method will need to make a decisions at each iteration in the loop.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!