• Post Reply Bookmark Topic Watch Topic
  • New Topic

Removing Elements From an Array  RSS feed

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know the proper syntax for removal of an element from a vector. Do I have this correct?
Example:
I have an object that contains a Vector of Strings named dataType.
I have an int variable named elementNumber that specifies the location of the element I want to remove.
Would I call the following method to remove the String Object?
dataType.remove(elementNumber)
Thanks,
Landon
 
fred rosenberger
lowercase baba
Bartender
Posts: 12529
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from the API
remove
public Object remove(int index)
Removes the element at the specified position in this Vector. shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the Vector.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!