ArrayList is based internally on a simple array, so when you delete by index you simply move everything that has higher index than the removed element one place down, look at te JDK implementation:
public E remove(int index) {
rangeCheck(index);
modCount++;
E oldValue = elementData(index);
int numMoved = size - index - 1;
if (numMoved > 0)
System.arraycopy(elementData, index+1, elementData, index,
numMoved);
elementData[--size] = null; // clear to let GC do its work
return oldValue;
}
Ofcourse the inner array (elementData) is package-access so you don't have access to it, that's the whole point. If you are implementing your own list I suggest extending the AbstractList. If you are not then this question doesn't make sense, like I said, that's the whole point of ArrayList to encapsulate the inner array so you can operate on it only through methods available to you.
If you want to delete not by index, but by passing some instance of type that the ArrayList is holding, that requires the equals check, so that type needs to properly override equals and hashCode methods.
java.util.ArrayListwithout callingremove()or how to implement remove(index) is some customArrayListlike class you are implementing?public static deleteMe(int index)this isn't even valid syntax... >_>ArrayListclass at all (not only without using itsremovemethod)?