0
/ 1.0
Use this interface definition to solve this exercise.
public interface ListADT<E> { // returns number of elements stored public int...
Use this interface definition to solve this exercise.
public interface ListADT<E> {
// returns number of elements stored
public int size();
// removes all elements
public void clear();
// return true if list is empty, false otherwise
public boolean isEmpty();
// adds e at the end of the list
public boolean add(E e);
// returns true if o is in the list, false otherwise
public boolean contains(Object o);
// returns the object at index, returns null if
// index is invalid
public E get(int index);
// returns the index of o if it exists, -1 otherwise
public int indexOf(Object o);
}
Write a test method to test the size()
of List<String>
.
The test infrastructure has an variable named instance
of type List<String>
. When your test is run, this
object has just been allocated.
Write at least 3 asserts to test the size()
of the
instance
object. You might want to check the initial
value of size()
, the add some objects, check size()
again, then call clear()
and check the size again.
Your feedback will appear here when you check your answer.