Question
In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayListMethods. Create three static methods: print- This method
In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayListMethods.
Create three static methods:
- print- This method takes an ArrayList
as a parameter, and simply prints each value of the ArrayList on a separate line in the console. - condense- This method takes an ArrayList
as a parameter, and condenses the ArrayList into half the amount of values. While traversing, this method will take the existing value at the index and add the index following to the existing value. For example, if we had an ArrayList that consisted of Strings ["0", "1", "2", "3"], the ArrayListMethods.condense(["0", "1", "2", "3"]) would alter the ArrayList to be ["01", "23"]. - duplicate- This method takes an ArrayList
and duplicates the value of the index at the position index + 1. As a result, ArrayListMethods.duplicate(["01", "23"] would be ["01", "01", "23", "23"].
If done correctly, the methods should work in the ArrayListMethodsTester file.
Coding below was given to be edited
import java.util.ArrayList; public class ArrayListMethodsTester { public static void main(String[] args) { ArrayList
import java.util.ArrayList; public class ArrayListMethods { }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started