• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap and ArrayList  RSS feed

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In an interview...i had a question...where i was asked...


In a web application ..among these 2 data structures...which would you use...

I would like to have a more precise answer...

Regards
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i would say it depends on the situation. i don't believe there is EVER a single, always correct answer. press for more info on how they are going to use this data structure... what kind of info goes in it, how will it be accessed (and how often), are duplicates allowed, etc.

without that info, you can't answer the question.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by fred rosenberger:
...press for more info on how they are going to use this data structure... what kind of info goes in it, how will it be accessed (and how often), are duplicates allowed, etc.

without that info, you can't answer the question.

Indeed, I suspect that's what they might really be looking for with such a vague question.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you use a hammer or a band saw?

Depends upon the job, doesn't it?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question itself is nonsense; it is like asking: "When you need to drive from Amsterdam to Paris, what would you choose: a red car or a blue car?".

HashMap and ArrayList are two different data structures. Which of them you need, depends on what the application needs to do - it doesn't matter if it is a web application or any other kind of application.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all,

It is definitely as you have all have said...i should have asked for more info ...to clarify the requirements and then decide..


Regards
 
Ramasubbhu Allur Kuppusamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marc Weber:

Indeed, I suspect that's what they might really be looking for with such a vague question.


Interesting thought.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!