• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Collections Question

 
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

Best of luck!
 
Deepak Lal
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't you think of any opportunities to use a list or a map?
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Deepak Lal
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please provide me with code scenario examples ?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Deepak Lal
Ranch Hand
Posts: 603
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apart from these scenarios ,any more illustrations please
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Deepak,

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.
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic