Let's say that i have an array of objects.
So, I need to delete the count objects starting at the given index. Make sure to compress myObjects and update currentObject. You must also verify that the given index exists in myObjects and that there are count entries starting from there.
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:
public class ObjectArray {
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 code:
public void deleteObjects(int index, int count) {
if (index < count){
for(int i = count; i < myObjects.length - 1; i++){
myObjects[i] = myObjects[i + 1];
}
currentObject = myObjects.length - (count * index);
}
}
NOTE: I asked one similar question before but with deleteObject(int index) and i fixed it.
Thanks