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
How do you sing an Applet ?
Which software is used for java programming?
What is ide with example?
What is variable declaration and definition?
Explain 5 io best practices?
What is a method in programming?
Can an object subclass another object?
What are recursive functions?
Is null keyword in java?
What is use of static in java?
What are measurable parameters?
Is java hashset ordered?
Why we go for collections in java?
Describe the various concepts related to object oriented programming (oop).
Can you override static methods?