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 SimpleTimeZone class?
What is the main purpose of serialization in java?
What is runtime polymorphism or dynamic method dispatch?
What methods are used to get and set the text label displayed by a button object?
What is port number in java?
What methodology can be utilized to link to a database?
Is java written in c?
Why is string class considered immutable?
Explain the importance of throws keyword in java?
In the below example, what will be the output?
Write code to implement bubble sort in java?
How do you square a number in java?
What is the difference between static and global variables and also define what are volatile variables?
Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain
Can java arraylist hold different types?