Map map = new HashMap(2);
map.add(“1”,”one”);
map.add(“2”,”two”);
map.add(“3”,”three”); What will happen at this line?
Answer Posted / sreekanth madamanchi
We don't have a method add() in HashMap.
We have put().
Map map = new HashMap(2);
map.put("1","one");
map.put("2","two");
map.put("3","three");
System.out.println("Size of the map="+map.size());
If we wrote like this, it will extend the size.
The out put is: Size of the map=3
Is This Answer Correct ? | 18 Yes | 2 No |
Post New Answer View All Answers
What is += mean in java?
Can two objects have same hashcode?
What is a class in java?
What is the difference between the paint() and repaint() methods in java programming?
What is method and methodology?
Give some features of interface?
What is getkey () in java?
Differentiate between the constructors and methods in java?
What is the difference between private & public & friendly classes?
Why webdriver is an interface?
What is the difference between stringbuffer and stringbuilder class?
What is the difference between multitasking and multithreading in Java
If two threads have same priority which thread will be executed first ?
What about static nested classes in java?
Explain the difference between jdk, jre, and jvm?