posted 23 years ago
Hi,
What's the best way to iterate thru a collection(say a Vector)?
Should I get the Iterator for this Vector, and use it as in the following?
Vector someVector = new Vector();
//code to populate the vector
Iterator iter = someVector.iterator();
while (iter.hasNext())
{
Object obj = iter.next();
//do Some thing with the Object
}
Or is it better to avoid the iterator and use the Vector directly as follows?
for(int i=0; i< someVector.size(); i++)
{
Object obj = someVector.elementAt(i);
}
Any help in this regard would be appreciated.