6 Replies Latest reply: Mar 1, 2011 8:23 AM by Leaf Woods RSS

    List: toArray() vs. iterator, which is more efficient

    Leaf Woods
      Hi

      I have a List to process (jdk1.5). I could use toArray() to turn it to an array and use for loop to process the elements one by one. Or I could use its iterator. Which is more efficient?

      PS: One way direction. The elements have to be processed one by one in natural order. I didn't see the benefit to convert it to an array unless it is more efficient.

      Thanks

      Lin