aspose file tools*
The moose likes Beginning Java and the fly likes replace elements in vector in jdk 1.3.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "replace elements in vector in jdk 1.3.1" Watch "replace elements in vector in jdk 1.3.1" New topic
Author

replace elements in vector in jdk 1.3.1

peter brews
Ranch Hand

Joined: Jan 25, 2002
Posts: 59
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

Joined: Sep 13, 2002
Posts: 331
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


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: replace elements in vector in jdk 1.3.1