File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Doubt on Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt on Collection" Watch "Doubt on Collection" New topic
Author

Doubt on Collection

Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
Can any one tell where collections are used in Real world Projects. An Example


Ramesh Shanmugam - SCJP 1.5
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

They are used absolutely all the time. Anywhere you need a data structure which holds collections of objects.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
Can you please give me a small example
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Ehm, OK. The application I am currently working on hold user authorisation data (i.e. the various roles a user may belong to) in a Map. That do?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
If you've done some database modeling or UML you've seen one-to-many relationships, like parent has many children. When we do these in Java the "one" often has a collection of the "many" things.

Any time you find yourself saying "for each" or "for every" like "for each child, pay weekly allowance" you're probably going to find a collection.

Any of that help?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Vj Kamath
Greenhorn

Joined: Nov 19, 2004
Posts: 15
Collections are used to store objects.
Some real world examples:

HashMap could be used to store key value pairs to load a dropdown box.
ArrayList could be used to store the data returned into a resultset from a database.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Ramesh Shanmugam:
Can any one tell where collections are used in Real world Projects. An Example

Are you asking for specific code examples or high-level conceptual examples? If the later, all you have to do is turn on your computer to see Collections (or in computer science parlance, data structures) in action. Okay, you probably don't actually see them, but the operating system uses them under the hode constantly. For example, the printer has a queue to keep track of the next job to print. A program uses a stack to keep track of the address of the instruction when a function is called so that it can return there when the function returns.

These are quite low-level system examples, but as the other examples given above, there are also higher-level examples as well.

Cheers and Keep Coding (TM)

Layne


Java API Documentation
The Java Tutorial
 
Don't get me started about those stupid light bulbs.
 
subject: Doubt on Collection