This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

container, Iterators , Collection ?

 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Intermediate forum..
 
Warren Dew
blacksmith
Ranch Hand
Posts: 1332
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 253
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic