Question: In Java: Create an addBefore and add method to the class IntArrayList. The method addBefore adds an element to the beginning of an array, at
In Java: Create an addBefore and add method to the class IntArrayList. The method addBefore adds an element to the beginning of an array, at index 0, causing all existing elements to move forward (their indexes increased by 1). The method add creates an element at the end of the array. There are several ways to accomplish this task. Perhaps the easiest: double the array when you hit the beginning or end, copying it to the beginning or end dependent on if you're in the add or addBefore method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
