Discuss ArrayList Remove Method in the Java Help forum on Dev Shed. ArrayList Remove Method Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
Time spent in forums: 6 h 46 m 22 sec
Reputation Power: 1
ArrayList Remove Method
I am trying to write a remove method for an ArrayList class. I cannot use any built-in Java collections. I have been trying for at least a few days trying to figure this algorithm out, but nothing is working.
Here is what I have so far...
//Remove the element at the given index and returns it.
public E remove(int index)
E result = get(index);
for (int x = index; x < count - 1; x++)
data_store[count - 2] = data_store[count - 1] ;