Let's say that i have an array of objects.
So, I need to delete the object at the given index and make sure to compress myObjects and update currentObject. Also, I have to verify that the given index exists in myObjects.
This is what I got:
NOTE: I will just show part of my program, because it's a long program but everthing is working well so far...
First: Those are my attributes:
private final int INITIAL_ARRAY_SIZE = 10;
private final int ARRAY_EXPAND = 20;
private Object[] myObjects = new Object[INITIAL_ARRAY_SIZE];
private int currentObject;
And this is my deleteObject(int index)
public void deleteObject(int index) {
for(int i = index; i < myObjects.length - 1; i++){
myObjects[i] = myObjects[i + 1];
}
How can I update my currentObject and compress myObjects?
Do I need something that compress it?