Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help import java.util.Arrays; public class ArrayList { 1/class variables private int numElements = 0; private int currCap = 100; private Object'l list = new

please help image text in transcribed
image text in transcribed
image text in transcribed
import java.util.Arrays; public class ArrayList { 1/class variables private int numElements = 0; private int currCap = 100; private Object'l list = new Object (100); public void insert(Object obj, int index) { 1/extends the ArrayList if current capacity is reached if(numElements == list.length) { currCap*=2; list = Arrays.copyof(list, currCap); } //bumps all current elements up 1 index to make room for new object for(int i = numElements; i > index; i--){ list[i] = list[i-1]; //adds object list[index] = obj: numElements++://tracks number of elements } public void add(Object obj){ 1/expands the ArrayList if the current capacity is reached if(numElements == list. length) { currCap*=2; list = Arrays.copyof(list, currCap); } 1/adds the object to the farthest index list (numElements] = obj; numElements++; public Object remove(int index) { Object item = list[index]; for(int i = index; i index; i--){ list[i] = list[i-1]; //adds object list[index] = obj: numElements++://tracks number of elements } public void add(Object obj){ 1/expands the ArrayList if the current capacity is reached if(numElements == list. length) { currCap*=2; list = Arrays.copyof(list, currCap); } 1/adds the object to the farthest index list (numElements] = obj; numElements++; public Object remove(int index) { Object item = list[index]; for(int i = index; i

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions