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 / haneef

see, there is no add() in the Map, so u will get compilation
error.

there is only put();

Is This Answer Correct ?    22 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between equal and == in java?

688


What is tostring () method?

745


What is the purpose of abstract class?

686


What is java in detail?

800


Is java still necessary?

805






What do you mean by scope of variable?

649


FOR EXAMPLE WE R HAVING TWO LIST ELEMENTS ..BOTH LISTS CONTAINS ID,NAME,PLACE ..I NEED TO COMPARE BOTH IDS IN TWO LISTS,IF ID'S R SAME MEANS WE HAVE ADD THE DETAILS(LIKE NAME,PLACE) TO MAP...HOW IS POSSIBLE ?CAN ANY ONE SUGGEST?

2923


What is a stack class in java ?

814


What is the use of optional ?

767


What is contract between hashcode and equal method?

767


What is string variable?

762


If we don’t want some of the fields not to serialize how to do that?

763


What are the two ways of implementing multi-threading in java?

1124


Can we use both this () and super () in a constructor?

753


What is the buffer limit?

738