How to implement Hash Map?

Answers were Sorted based on User's Feedback



How to implement Hash Map?..

Answer / rice


HashMap is a class that implements Map interface.

HashMap underlined data structure is Hash table.

If we want to describe the group of objects as key ,value
pairs then we go for HashMap class.

key are not duplicated but value can be any thing.

null insertion is possible.

insertion order is not preserved.

HashMap hm=new HashMap();
hm.put(1, "rice");
hm.put(3, "rice");
hm.put(2, "shine");
System.out.println(hm);

Is This Answer Correct ?    2 Yes 1 No

How to implement Hash Map?..

Answer / brijendra-java (xavient)

HashMap is the implementaion of Map interface.
HashMap is key value pair storage concept.
HasMap does not allow duplicate key but value may be any
thing.
HasMap allow both key and Valuea as NULL.
HasMap is the Unordered collection.
When we change the iteration of HasMap then it give
concurrent Modification error.
HasMap is NonSyncronised class.

HashMap hMap = new HashMap();
hMap.put(Null, Null);
hMap.put(1, a);
hMap.put(2, b);
hMap.put(3, c);
system.out.println("Size"+hMap.size());

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Java Related AllOther Interview Questions

What is interceptor in java?

0 Answers  


What are anonymous methods and lambda expression?

0 Answers  


Write a program for the problem: the array of inetegers indicating the marks of the students is given, U have to calculate the percentile of the students aaccording to this rule: the percentile of a student is the %of no of student having marks less then him. For eg: suppose Student Marks A 12 B 60 C 80 D 71 E 30 F 45 percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him) percentile of B = 3/5*100 = 60% (out of 5, 3 have markses less then him) percentile of A = 0/5*100 = 0%.

0 Answers   Sapient,


What is csrf in java?

0 Answers  


What is java persistence api used for?

0 Answers  






What is a singleton in java?

0 Answers  


What is cdi bean in java?

0 Answers  


what diff bw constructor method & method

4 Answers   CTS,


What is jboss in java?

0 Answers  


Why do we only use the main method to start a program?

0 Answers  


What is the use of flatmap?

0 Answers  


What is adoptopenjdk?

0 Answers  


Categories