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 the significance of continue jump statement? Explain with an example.
State the difference between strings and arrays.
What is anagram of a string?
Can a private method of a superclass be declared within a subclass?
Explain about core java?
What is immutable state?
What is static import in java?
Is java an ide?
What is polymorphism and what are the types of it?
Are maps ordered java?
What is the difference between an interface and an abstract class?
What are variable arguments or varargs?
What is the main method java?
Is a class subclass of itself?
What is java abstraction with example?