Can we place the any object to key attribute of
HashMap<key,value>?

Answer Posted / patil abhijeet

Yes we can use object as the key

person p = new person();

HashMap m = new HashMap()
m.put(p,"mysqlf");
above works perfectly fy9 ..... but dont try to use the same
object as key twice :-)

Is This Answer Correct ?    5 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What classes of exceptions may be caught by a catch clause in java programming?

693


Explain numeric promotion?

589


What are the main features of java?

523


What does it mean to flush a file?

560


What is meant by class loader? How many types are there?

667






Can a abstract class be declared final?

556


How to create com object in Java?

641


What is a 16 bit word?

558


How are variables stored in memory?

568


Are generics important java?

516


List down the methods and interfaces of collection class in java.

533


What is the purpose of tostring() method in java?

544


What is the maximum size of a string in java?

543


Why heap memory is called heap?

578


What is protected access modifier?

565