In which scenario can i use the below Collections (can you give me a real time example where i can apply the below Collections Frammework and Why ?)
a>ArrayList b>Linked List
c>Vector
d>HashMap e>HashTable
f>Queue
When The Going Gets Tougher,The Tougher gets Going
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
posted
0
Deepak Lal wrote:In which scenario can i use the below Collections (can you give me a real time example where i can apply the below Collections Frammework and Why ?)
a>ArrayList b>Linked List
c>Vector
d>HashMap e>HashTable
f>Queue
Hello! Your post shows a homework vs interview vs certification question, but you haven't shown your thoughts on a solution yet, and this is critical in helping us identify what you know and what you're confused on. Please read these sections of the FAQ for more on this: ShowSomeEffort, DoYourOwnHomework, NotACodeMill, TellTheDetails
I know the below concepts,BUT i want to know some REAL TIME EXAMPLES for the below where they can be used.
a>ArrayList -- Unsynchronized Data Structure
b>Linked List is based on Doubly linked List Data Structure
c>Vector -- Synchronized Data Structure
d>HashMap -- Unsynchronized Data Structure
e>HashTable -- Synchronized Data Structure
f>Queue -- Based on Dequeue Data Structure
I wanted some real time scenarios where the above said Collections can be applied in Java Based Applications.Could you please advice/Suggest now.?
Can't you think of any opportunities to use a list or a map?
Vinod Vinu
Ranch Hand
Joined: Aug 30, 2009
Posts: 217
posted
0
Can't you think of any opportunities to use a list or a map?
Map:-
Use map when you want to store only unique elements like
two table are there emp_table with emp_id(primary key) and bank account with acc# (primary_key)
create a map for this such that 1emp_id corresponds to 1 or more acc# because an emplyoee can have mulitple bank accounts but an account cannot be corresponds to more than 1 emp_id
List:-
When to just want to add elements (can be duplicate elements) . you have indexed of these elements in your hand . resizable array
Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
A list of employees that have signed up for a seminar. That's an example of a list.
A map of employees to their office/cubicle information (like number of ethernet connections and their IPs, location, etc.). That's an example of a map.
these are actually very basic data structures that should be known to any programmer and they exist since the dawn of programming. There is nothing really special about them. It is a bit like asking illustrations for the use of + or * operators. Which scenario is best to illustrate multiplication?
There are hundreds of Lists, Sets or Maps in my current project. However none of them is so special as to serve as a good illustration, better than simple description 'this is a list of contracts', 'this is a map of customer ids to customers' or 'this is a set of refused identifiers'. However, to get the basic image, I'd strongly suggest to thoroughly read this tutorial: http://download.oracle.com/javase/tutorial/collections/interfaces/index.html. (I read this myself when I started using Java.)
The best way to get familiar with these structures is to use them in real code. If you have a question then, it will probably be 'which data structures to use in this situation I have', and that would be probably answered pretty well on this forum.
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.