File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes help reg collections utility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help reg collections utility" Watch "help reg collections utility" New topic

help reg collections utility

sathish gopal

Joined: Dec 30, 2000
Posts: 21
I have list object. i want to get all the elements from them.
i used a method add(int index) to get all the elements from them.
When i carefully looked at the API there is Interface called Iterator which can also be used to get elements out from the list.
Which is the best and efficient way..
I am using JDK 1.4.2
marc weber

Joined: Aug 31, 2004
Posts: 11343

I definitely recommend learning about iterators. A great place to start is this section from Bruce Eckel's Thinking in Java.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
I would think that the add(int) method would offer very poor performance in getting values from a list.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: help reg collections utility
It's not a secret anymore!