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 original name of java?

1031


What is the importance of hashcode() and equals() methods?

1017


What is wrapper class html?

899


Explain about automatic type conversion in java?

1019


What is a databasemetadata?

909


Is java ee a framework?

941


What do you mean by pointer value and address?

1009


How can I debug the Java security exceptions and AccessControlExceptions?

1100


What is this keyword in java?

997


Can we pass null as argument in java?

905


what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread

930


Explain about anonymous inner classes in java?

1018


What are recursive functions?

994


Can we override private method?

1050


Difference between final and effectively final ?

1035