When creating a game and you want to delete something from the screen that is in an ArrayList, lets say a bullet, is it viable to use arrayList.remove(index)
to remove it from the game? or is it still using up memory when done this way?
If this is not the preferred way to do it, please point me in the right direction :)
The answer is possibly. Removing the bullet from the ArrayList
will eliminate a reference to it. If there are no other references, then the bullet object will be GCed eventually.
The screen of course will have to redraw itself without the bullet and that is a mostly separate issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With