Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / abhijeet

Hi,
I am giving you a collective answer. Yes you can use any
object as key in hashmap. But if you r sure that u will be
using diferent objects as key then u dont ve to overide
anything. But if you are going to use same object as key
then you need to override hashcode and equals method. Be
sure that your equals method returns false if you need to
use the object as key.

But this is tricky 1 and in live enviroment its not needed :-)
only for interview to impress interviewwer :-)

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the benefit of abstract class?

950


How do you invoke a method?

1010


Can you explain inner class.

1093


How many types of string data types are there?

1098


Does substring create a new object?

1003


What is the benefit of lambda expressions?

1068


Why do people says “java is robust”?

1041


What is main method?

1049


What is the access scope of a protected method?

1034


What is java volatile?

1062


What is the += operator called?

1066


List the interfaces which extends collection interface?

959


What are instance variables?

1086


Explain the usage of this with constructors?

1029


Compare java and python.

996