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, 23.06.2019 18:00
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a.edit the sizes and other characteristics of photos that have been inserted. b.take a screenshot of an image and copy it to the clipboard for pasting. c.search for drawings or other images from a library of prepared pictures. d.make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
question
Computers and Technology, 24.06.2019 09:00
Why might you chose to crest a function resume
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
Which of the statements below describe the guidelines for the use of text in presentation programs? a. do not use numbered lists. b. fonts should be appropriate for your audience. c. limit the number of fonts you use to three or four. d. only use bulleted lists for sales promotions. e. select font sizes that are appropriate for your delivery method. f. use font colors that work well with your background. select all that apply
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Which type of excel chart should be used to track students’ progress on test grades? line column bar pie
Answers: 2
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
Chemistry, 16.04.2021 18:50
question
Mathematics, 16.04.2021 18:50
question
Mathematics, 16.04.2021 18:50
question
Mathematics, 16.04.2021 18:50
question
Mathematics, 16.04.2021 18:50
Questions on the website: 13722361