Thursday, February 7, 2002 01:22 PM
An array is advantageous for two reasons. First, an iterator always returns an object, and you have to cast the right class to get what you wanted, which takes some cpu time. Also, when getting a object, you have call a method, which creates a lot of overhead in a loop. An iterator can be useful when you have a list of variable length, or you want to prevent some other class from accessing directly some method for a collection, for example add().