/** for (int i = size; i >

/** * Your implementation of an ArrayList. * * @author Peiyu Wang * @version 1 */public class ArrayList implements ArrayListInterface {
// Do not add new instance variables. private T backingArray; private int size;
/** * Constructs a new ArrayList. * * You may add statements to this method. */ public ArrayList() { backingArray = (T) new ObjectINITIAL_CAPACITY; size = 0; }
@Override public void addAtIndex(int index, T data) { if (data == null) { throw new IllegalArgumentException(“Error,data is null”); }
if (index size) { throw new IndexOutOfBoundsException(“Error, index is negative” + “or larger than Array size”); }
if (size >= backingArray.length) { T temp = (T) new Object2 * backingArray.length; for (int i = 0; i index; i–) { backingArrayi = backingArrayi – 1; } backingArrayindex = data; size = size + 1;

}
@Override public void addToFront(T data) { if (data == null) { throw new IllegalArgumentException(“Error,data is null”); } if (size >= backingArray.length) { T temp = (T) new Object2 * backingArray.length; for (int i = 0; i 0; i–) { backingArrayi = backingArrayi – 1; } size = size + 1; backingArray0 = data;

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

}
@Override public void addToBack(T data) { if (data == null) { throw new IllegalArgumentException(“Error,data is null”); } if (size >= backingArray.length) { T temp = (T) new Object2 * backingArray.length; for (int i = 0; i = size) { throw new IndexOutOfBoundsException(“Error, index is” + ” negative or larger than Array size”); } if (size == 0) { return null; }
T temp = backingArrayindex;
for (int i = index; i = size) { throw new IndexOutOfBoundsException(“Error, index is negative ” + “or larger than Array size”); }
return backingArrayindex; }
@Override public boolean isEmpty() { return size == 0; }
@Override public int size() { return size; }
@Override public void clear() { backingArray = (T) new ObjectINITIAL_CAPACITY; size = 0; }
@Override public Object getBackingArray() { // DO NOT MODIFY. return backingArray; }}

x

Hi!
I'm Shane!

Would you like to get a custom essay? How about receiving a customized one?

Check it out