Can HashMap store null values?If yes, how many?

Can HashMap store null values?If yes, how many?

What is singleton class? Give one example.

Please describe the difference between 'int' and 'Integer',
what is the purpose of 'Integer', where should we use 'Integer' vs 'int'?

Questions by Namataraginu

Showing Answers 1 - 9 of 9 Answers

fcasttro

  • Mar 22nd, 2008
 

Map Won't allow duplicates, So It will accept one null value.

HashMap map = new HashMap();

map.put(

null, null);map.put(null, null);

map.put(null, null);

After adding 3 null key / value pairs. It will show only one null value.

int => Primitive
Integer =>Object  (Wrapper Classes)

Wrapper classes are used to access the primitives(int) as Objects.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions