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 many bytes is a string?
What are 3 boolean operators?
Explain importance of inheritance in java?
What ide should I use for java?
What is hash table in java?
Discuss 2D arrays.
Write a program to check for a prime number in java?
What are the uses of java?
What is floating data type?
Name few java 8 annotations ?
Why collection is called framework in java?
What is thread safe singleton?
What is incompatible types in java?
What is the synonym of procedure?
What is oop principle in java?