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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is concurrent hashmap and its features?

524


Why we use protected in java?

534


Define Multiprogramming and Multiprocessing in java.

577


Explain a few methods of overloading best practices in java?

511


Can a function return a function?

550






What is charat java?

542


What is the string function?

557


What is Classloader in Java?

638


How does callback work in java?

607


Explain the difference between the public, private, final, protected, and default modifiers?

549


What is a copy constructor in java?

580


What language is an assembler written in?

551


What are the differences between Java 1.0 and Java 2.0?

1679


Why we use multi threading instead of multiprocessing?

575


Explain java coding standards for constants?

575