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 change an int to a string?
What is your platform’s default character encoding?
What is token in java?
How does regex work?
What is a for loop in java?
What is the static method?
what is optional in java 8?
When would you use a static class?
What is identifier give example?
Which browsers work with java?
Realized?
Is null a value?
What is the difference between hashmap and hashtable? What is an interface?
Can we create a constructor in abstract class?
How do you use equal in java?