As the previous poster said, you should not do this "by hand", but should use toArray() method.
However, if you were to do something like this "by hand", the right approach would depend on the exact type of List. An ArrayList will give slightly better performance using get(int index), whereas a LinkedList will give much better performance using Iterator. Using get(int index) on a large LinkedList will be seriously slow: O(n^2), I think.
If you do not know the actual exact type of List, it is best to use an Iterator.
In Java 5+, you can and should use "enhanced for" loop.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads