How do I create a class called MyArrayList which acts just like Java's ArrayList class? And how do I implement an interface exactly like Java's List interface, and for your class to the two constructors given below? You are given the MyListInterface: abstract class MyListInterface extends java.util.AbstractList { abstract public int size (); abstract public void clear (); abstract public boolean add (final Integer element); abstract public Integer get (final int index); abstract public Integer set (final int index, final Integer element); abstract public Integer remove (final int index); abstract public boolean remove (final Integer element); abstract public String toString(); } How do I create an array of type Integer[] with some initial size and keep track of the number of elements actually in use in the array? When it reach the size limit of the array, it must grow the array by creating a new array and copy elements from old array. Here is a list of the necessary constuctors: public MyArrayList(): Constructs an empty list with an initial capacity of 10 public MyArrayList(int initialCapacity): Constructs an empty list with the specified initial capacity
How do I create a class called MyArrayList which acts just like Java's ArrayList class? And how do I implement an interface exactly like Java's List interface, and for your class to the two constructors given below?
You are given the MyListInterface:
abstract class MyListInterface extends java.util.AbstractList {
abstract public int size ();
abstract public void clear ();
abstract public boolean add (final Integer element);
abstract public Integer get (final int index);
abstract public Integer set (final int index, final Integer element);
abstract public Integer remove (final int index);
abstract public boolean remove (final Integer element); abstract public String toString();
}
How do I create an array of type Integer[] with some initial size and keep track of the number of elements actually in use in the array? When it reach the size limit of the array, it must grow the array by creating a new array and copy elements from old array.
Here is a list of the necessary constuctors:
- public MyArrayList():
Constructs an empty list with an initial capacity of 10
- public MyArrayList(int initialCapacity):
Constructs an empty list with the specified initial capacity
Trending now
This is a popular solution!
Step by step
Solved in 3 steps