aspose file tools*
The moose likes Beginning Java and the fly likes Question: Where and when should I use the collection (Lists, Stack, etc . . .) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question: Where and when should I use the collection (Lists, Stack, etc . . .)" Watch "Question: Where and when should I use the collection (Lists, Stack, etc . . .)" New topic
Author

Question: Where and when should I use the collection (Lists, Stack, etc . . .)

Preston Thornton
Ranch Hand

Joined: Jun 24, 2008
Posts: 80
Good morning from Detroit, Michigan:

I have a question about using the java collection (Stack, Lists, etc.). I have taken the basic and intermediate programming classes in C++ and Java. I am about to start a class in C++ focus in data structures. Now I have already read up, or have had some exposure to the to this topic before in java, but I still have not truly seen how you use Stack, Lists, and such is used in the development of an out-the-self application in a situation such as memory management of a accounting package, or video game. So, where do you use them in the real world.

Preston.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
In accounting, you might have Account objects, or Expense objects, which might go in a List. [A lot of accounts packages actually link to a database, however.]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

We use queues all the time for message processing. the sending applications can all write to the queue, and there messages get interleaved (i.e. message 1 is from application 'a', message 2 is from 'b', message 3 from 'a', 4 from 'c', etc).

But all the messages from application 'a' have to be processed in order. the program that reads and process the messages pulls them off in order.

using a queue allows many applications to write at whatever rate they want to the queue, and the processing application to read them off at whatever rate it wants to.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

These data structures are used *everywhere*, literally (although you didn't mention maps, which are also ubiquitous). Google maps: a route is a list of waypoints. Games: there's a list of sprites (and a prioritized queue of events). Shopping *list*. *List* of account transactions. *List* of memory references. *Maps* of file system entries.

*List* of things that use collections.
Preston Thornton
Ranch Hand

Joined: Jun 24, 2008
Posts: 80
Okay! Thanks for the focus adjustment on this topic. I will make sure that I pay full attention in regards to these topics in the Data Structure course.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

A structures class (or just the knowledge, barring a class) is critical, and has remained one of the most important classes I took some 25 years ago.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

also, remember that learning should be cyclical. your prof. will say "this is important, but you won't necessarily understand why yet". It took me a few years before I really understood why/how using interfaces was a good idea. I did it, because they told me to, but i wasn't sure why. As i learned more about other things, i gradually realized why they are so powerful.

it's the same with data structures. You may not see an immediate need for one, and it may seem odd that anybody would ever come up with such a thing. Just remember that someone, somewhere needed EXACTLY THAT, and other soon realized it would solve their problems too. Almost all of them will seem silly, until you need EXACTLY THAT.

some of it you just have to take on faith.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question: Where and when should I use the collection (Lists, Stack, etc . . .)
 
Similar Threads
constructor question
Stack Vs. Heap
post increment confusion
Difference b/w import & #include in C++
Heap and Stack in memory