Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Java Vector -- removeElement(Object)

Started by Halsafar Oct 22, 2005 at 7:38 PM 1 replies 700+ views
Original Post
Halsafar
Halsafar
When you call Vector.removeElement(obj) to have the vector eliminate the first instance of the particular object you pass in does it remove the index or set it to null? See I have it working fine, but now it comes to question... When I call removeElement does it just set the index to null or does it remove the index thus collasping the array down a size.
stormrunner
stormrunner
The Vector documentation for Vector.removeElement states that both the element and index are removed.

Quote:
Removes the first (lowest-indexed) occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.
stormrunner
Halsafar
Halsafar
So in my case since I need the index to remain I should just set that particular index to null.

I did read the java vector javadoc but I didn't find that particular line you posted.

Thanks,
Halsafar

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.