Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector elements into Iterator

 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
How can i get the vector elements into Iterator collections object?
Thanks in advance.
Ravi
 
Vikas Varma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it could be done in this way..
java.util.Vector v = new java.util.Vector();
for (int i = 0; i < 10; i++) {
v.addElement("element " + i);
}
java.util.Iterator itr = new java.util.Iterator();
itr = v.iterator();
while (itr.hasNext()) {
//Do your stuff
System.out.prinltn("element " + itr.next());
}
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vector.iterator()
 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Vikas Varma & Ron Newman,
Thanks for your help.
Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic