Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JAVA) Modify the existing ArrayLists's contents, by erasing the second element, then inserting 100 and 102 in the shown locations. Use ArrayList's remove() and add()

(JAVA) Modify the existing ArrayLists's contents, by erasing the second element, then inserting 100 and 102 in the shown locations. Use ArrayList's remove() and add() only. Sample ArrayList content of below program:

100 101 102 103 

why doesn't the code under *solution goes here* work? Thank you!

CODE:

import java.util.ArrayList;

public class ArrayListADT {

public static void main (String [] args) { ArrayList numsList = new ArrayList(); int numOfElem = 4;

numsList.add(new Integer(101)); numsList.add(new Integer(200)); numsList.add(new Integer(103));

/* Your solution goes here */ numList.remove(1); numList.add(0,new Integer(100)); numList.add(2,new Integer(102)); printArray(numsList, numOfElem); return;

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions