• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

code for arraylist and hashmap

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In one of inteviews,the following questions we asked
1)Interviewer asked me to write a class that should work as arraylist .
2)Interviewer asked me to write a class that should work as hashmap.

can any body provide code for classes those work like arraylist and hashmap
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I moved this to "Jobs Discussion" so someone can explain to you why this request is so offensive.
 
author
Posts: 23899
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm not sure of the purpose here. Is the goal to memorize the arraylist and hashmap source, so that when the same question is asked, you can answer the question? I think it may be more productive to try to write it yourself -- this way, when asked again, you can reproduce it during the interview.


Regardless, if you really want to see the source. The source for the arraylist and hashmap classes should be included with your Java install (if you have the full SDK). It is part of the source file located at src.zip.

Henry
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Such questions are usually followed by discussion on performance improvements and time space trade offs. You should probably follow Henry's suggestion and try to do it yourself. Only when you understand the implementation can you discuss any improvements to it.

Hint -> Think of how lists can be implemented with an array. What are the methods that a List must have ?

With hash maps there is so much to discuss. Here is a starter Hash table.
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic