Well, I have a have a primitive array of objects, and because I can't remove them from the array, I instead change the object's position in the array to null. However, if I want to iterate over each object in the array, in the following way:
for (Derp derp : derps){
derp.herp++;
}
Do I have to do something like this?
for (Derp derp : derps){
if (derp != null){
derp.herp++;
}
}
Or would it be fine the first way I had it? Will the for loop 'know' that it only has to iterate over the Derp objects, and not the null objects, because I've declared it as a Derp object? Or perhaps it just treats it as a Derp object because I've said it would be, and it would cause an error when it tries to iterate over a non-Derp object? Or is null still a Derp object, just one that is null? Which is it, and what code can I use?
Alternatively, how can I remove an object from a primitive array and not leave a null object and actually shorten the length of the primitive array?