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
Is java free for commercial?
Write code of any action class?
Can a method be static?
How do you stop a thread in java?
What are actual parameters?
What is core java called?
What are the differences between the constructors and methods?
What is difference between identifier and variable?
Define how can we find the actual size of an object on the heap?
Why are lists ordered in java?
Difference between static and dynamic class loading.
Difference between abstract and concrete class ?
List out five keywords related to exception handling ?
What is the largest data type in java?
Explain working of call by reference function invoking.