Question: Java The class IntList as defined below stores a list of integers using an internal array. Implement the method add so that it can add
Java The class IntList as defined below stores a list of integers using an internal array. Implement the method add so that it can add any number of integers to the list by automatically doubling the size of the internal array when it becomes full.
class IntList { private int[] a; // internal array to store integers private int length = 0; // size of the list IntList() { a = new int[10]; } // initial size of the array is 10 // add integer x to the list and double array size as necessary void add(int x) { // TODO }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
