Question
We have completed chapter 7 (on arrays). We covered basic array syntax, differences between arrays of primitives and arrays of reference types, array initializer lists,
We have completed chapter 7 (on arrays). We covered basic array syntax, differences between arrays of primitives and arrays of reference types, array initializer lists, multi-dimensional arrays and Java API support. We also look at how the main method's String array "args" parameter works. We did not cover defining methods with variable argument lists.
Overview:
This lab works with a type in the Java Class Hierarchy API that manages Collections more flexibly than the static arrays provided by the Java language syntax.
Description:
You can follow the discussion of the java.util package's ArrayList class from the textbook or the lecture, but I'm hoping you will be prompted to review the Java online documentation at:
https://docs.oracle.com/javase/8/docs/api/ (Links to an external site.)Links to an external site.
You can do this exercise mentally, but it might be better if you write a Java program to implement an ArrayList instance of type String by performing the following operations:
Instantiate an ArrayList containing type String members.
add "a"
add "day"
add "bad" at index 1
add "good"
add "day"
remove "bad"
add "any" at index 0
set "have" at index 0
remove at index 2
Now list the strings in sequence and copy the resulting message into your solution. Full credit for the correct answer. Possible partial credit if only a few mistakes, but there really shouldn't be any mistakes if you simply implement the solution as a Java program.
I need java code
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