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
What are the disadvantages of using inner classes?
What does system.gc() and runtime.gc() methods do?
What happens if a constructor is declared private?
What mechanism does java use for memory management?
What is the basic of java?
Does java return by reference?
What is complexity in java?
What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
What is java util concurrentmodificationexception?
Can java arraylist hold different types?
What is increment in java?
What does jenkins do?
What is difference between public static and void?
What are namespaces in java?
Explain the difference between transient and volatile in java?