This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Similar Threads
Sorting a stack
Getting all of the elements from an HttpServletRequest
rich faces pick list with valueChangeListener attribute ( not working)
XML One liners for the exam....