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 Java in General and the fly likes  container, Iterators , Collection ? 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 » Java in General
Bookmark " container, Iterators , Collection ?" Watch " container, Iterators , Collection ?" New topic
Author

container, Iterators , Collection ?

Siva kandasamy
Ranch Hand

Joined: Dec 31, 2002
Posts: 139
Hi there,
a) Can you explain what is

1. container
Is array is also a container ?

2. Iterators
Why Iterators ?

3. Collection
4. Collections
What is the relation between Collection and Collections.

5. Comparable
6. Comparator
What is the relation between Comparable and Comparator.

thanks
siva
nikos sokaf
Ranch Hand

Joined: May 01, 2004
Posts: 57
The informations you need you will find on java.sun.com tutorials...

I suggest you to check out all the java.util.* package.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Intermediate forum..


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
    
    2
2. While iterators don't always save much typing over manual iteration, using them tends to result in a fewer bugs, and thus less debugging time. They also tend to be a bit more legible, once you get used to them.

3&4 A Collection is just that - a collection of objects. The Collections class provides useful static methods for use with the various Collection subclasses.

5&6 A Comparator is a thing that does the comparing. Something that implements Comparable is something that gets compared.

A Comparator is typically written to compare two things that aren't normally compared, or to compare them in a different way than normal. Things that implement Comparable are expected to be compared, and can be compared without writing an explicit Comparator class.
Herb Schildt
Author
Ranch Hand

Joined: Oct 01, 2003
Posts: 239
Siva:

As a point of interest, with the new Java 2, v1.5 (tiger), Java supports a "for-each" style of for loop that automatically iterates over a collection. Its use simplifies the code that cycles through a collection. Given your current line of questioning, you might want to check it out.


For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com
 
 
subject: container, Iterators , Collection ?
 
Similar Threads
What is the difference between Comparator and Comparable
Comparator & Comparable
diffrence between collection n collections
Comparable and Comparator
comparator and comparable interfaces