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

A person says that he compiled a java class successfully without even having a main method in it? Is it possible?

1111


What is java string pool?

1060


What is the difference between assignment and initialization?

1098


Why is whitespace important?

1145


What are the super most classes for all the streams?

2694


Program to Find the second largest element in an array.

1262


What’s a deadlock?

1147


What is java in detail?

1129


What is a null point?

1154


What is string and its types?

1258


What is a constructor, constructor overloading in java?

1045


What is == and === in javascript?

1108


Explain the difference between serializable and externalizable in java?

1140


what is the difference between yielding and sleeping? : Java thread

1010


What is treemap in java?

1042