Hi Friends, Can u give few interview questions which relates
ArrayList and Hashmap. I mean how to link ArrayList and
HashMap.I know this is not good way of asking questions like
this , but i need

Answer Posted / murali,25@gmail.com

HashMap stores key-value pairs. Alternate approach is to have a plain java class with key,value as attributes.
class HashMapAlternate{
Object key;
Object value;
}

You can create objects of HashMapAlternate and store it in arraylist. But HashMap is a better solution because it uses hashing and collision resolution technique which speeds up lookup when number of objects are very large.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are floats faster than doubles?

561


What does nextint () do in java?

552


Write an algorithm for quick sort?

615


Can we declare the static variables and methods in an abstract class?

544


What is a method declaration?

509






Differences between traditional programming language and object oriented programming language?

568


What is autoboxing and unboxing?

577


What are the uses of java?

566


What are the rules for naming an array?

520


What are design patterns and please explain?

566


Give a practical example of singleton class usage?

591


Give differences between Quicksort & Mergesort. When should these sorts be used and what is their running time?

569


What are the 5 types of research methods?

585


What are variable names?

526


What is boolean flag in java?

572