Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

replace elements in vector in jdk 1.3.1

 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I have vector of vectors
Vector VMaster - [[flag, 0,1,1], [state, NJ,NY,ALL],[f1,11,12],[f2,22,24,80,09]]
I need to replace some of the elements of this vector with new value.
For ex.
I need to replace
[flag,0,1,1] to [flag,false,true,true]
and
[state ,NJ,NY,ALL] to [state,newjersey,newyork,ALL]
so that the final vector should be like
[[flag,false,true,true], [state,newjersey,newyork,ALL] ,[f1,11,12],[f2,22,24,80,09]]
What changes should I make to following code:
can I use SetElementAt()

for (int i = 0; i < VMaster.size(); ++i) {
Vector subVect = (Vector) VMaster.elementAt(i);
String field1 = (String) subVect.elementAt(0);

for (int j = 0; j < subVect.size() - 1; ++j) {
if(field.equals("flag"))
{���.
����.
}
Thanks,
ag
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can use setElementAt() to do that. But, you should also really consider using an ArrayList instead for improved performance. The ArrayList has a similar method set() to accomplish the same thing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic