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
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.