Question
I need help with this section. 3.1 Write code that creates an ArrayList object named list and fills list with these numbers (using one or
I need help with this section.
3.1 Write code that creates an ArrayList
0123401234
I've written this code already for 3.1 but I need help writing the code for the following sections so I can see how they work...
import java.util.ArrayList;
public class HW1 {
public static void main(String[] args) {
ArrayList list = new ArrayList();
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 5; ++j) {
list.add(j); } }
System.out.print(list); } }
3.2 Consider the ArrayList
for (int i = 1; i < 10; ++i) { list.set(i, list.get(i) + list.get(i-1));
}
3.3 Write an enhanced for loop that counts how many numbers in an ArrayList
3.4 Write a method named arrayListSum() that has one parameter pList which is an object of the class ArrayList
3.5 Write a method named named arrayListCreate() that has two int parameters pLen and pInitValue. The method shall create and return a new ArrayList
3.6 Write a void method named insertName() that has two input parameters: (1) pList which is an object of ArrayList
3.7 Write a void method named arrayListRemove() which has two parameters: pList is an object of the ArrayList
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