Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: Java Implement an integer (int) ArrayList. You will need to create a new class for an integer ArrayList. Your data structure will internally use

Language: Java

Implement an integer (int) ArrayList. You will need to create a new class for an integer ArrayList. Your data structure will internally use an int array to store elements, which should be resized as necessary. Your ArrayList must support the following operations:

A method size(), that will return an int, with the current size (number of elements in the ArrayList) of the list. A method isEmpty(), that will return true if the ArrayList has no elements and false otherwise. A method get(int i), that will return the element at position i. A method set(int i, int x), that will set the value of the element at position i to x. A method add(int I, int x), that will add an new the element at position i with the value x. A method remove(int i), that will remove the element at position i from the ArrayList. Your methods need to deal with special cases, for example if an index i is outside of the bounds of the list. You have to make your own assumptions on how to handle border cases. You will need to document those assumptions and make sure you implement them correctly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions