Map map = new HashMap(2);
map.add(“1”,”one”);
map.add(“2”,”two”);
map.add(“3”,”three”); What will happen at this line?
Answers were Sorted based on User's Feedback
Answer / 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 |
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 |
Answer / raman t
if we write like this then it would be better.
HashMap map = new HashMap();
map.add( "cat", "Meow" );
map.add( "ape", "Squeak" );
map.add( "dog", "Woof" );
map.add( "bat", "Squeak" );
System.out.println( "map = " + map );
| Is This Answer Correct ? | 2 Yes | 14 No |
in a constructor what happen if u call super and this in the same class? i know that it is not possible to call both in the same one? if we call what will happen?
Is sizeof a preprocessor?
What is binary tree in java?
Explain some best practices you would apply while using collection in java?
Can we define constructor in inner class?
What will happen if we cannot mention "finally" in Java Program ???
What is math exp in java?
wahts is mean by thread?
22 Answers HCL, TCS,
Why we cannot override static method?
How do you end a program?
Can we able to pass objects as an arguments in java?
What is a reflection package?