subject

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.

[ArrayListMethodsTester. java]

import java. util. ArrayList;

public class ArrayListMethodsTester
{
public static void main(String[] args)
{
ArrayList stringArray = new ArrayList();
stringArray. add("This");
stringArray. add("is");
stringArray. add("an");
stringArray. add("ArrayList");
stringArray. add("of");
stringArray. add("Strings");

ArrayListMethods. print(stringArray);
System. out. println("\nArrayList is condensing:");
ArrayListMethods. condense(stringArray);
ArrayListMethods. print(stringArray);
System. out. println("\nArrayList is duplicating:");
ArrayListMethods. duplicate(stringArray);
ArrayListMethods. print(stringArray);

}
}

[ArrayListMethods. java]

import java. util. ArrayList;
public class ArrayListMethods
{

}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:30
At an open or uncontrolled intersection, yield if a. your road is paved and the crossroad is not b. the cross road is paved and yours is not c. you have two or more passengers in your vehicle d. you did not yield in the last intersection
Answers: 1
question
Computers and Technology, 22.06.2019 08:00
What is the first step in creating a maintenance ?
Answers: 2
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayL...
Questions
question
Business, 12.03.2020 18:24
Questions on the website: 13722360