Stephan van Hulst wrote:Not necessarily. Every collection has a toArray() method.
Ah, but the mechanics of the two aren't the same.
toArray() normally guarantees that it is "safe" (ie, a snapshot), and therefore won't show any changes subsequent to its creation.
But I completely agree with your first post, and
@maha:
You should know about the RandomAccess interface. Any List that does NOT implement it (eg, LinkedList) is likely to have very bad '
for(int i = 0...' style efficiency, but its Iterator will be as fast as it can be; which is why you should generally use
enhanced '
for' loops with Lists.
Winston