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 point of polymorphism java?

1007


Can constructor be protected in java?

961


Is a method a procedure?

1048


What are the 8 data types in java?

989


What is the vector class in java programming?

1077


How would you convert bytes to string?

982


Describe the term diamond problem.

1027


What is unicode in java?

925


What do you understand by the term wrapper classes?

999


Why doesn't the java library use a randomized version of quicksort?

993


Which sorting algorithm is best in java?

976


What are the characteristics of java?

1048


Describe the various concepts related to object oriented programming (oop).

1027


What are data structures in java?

969


What environment variables do I need to set on my machine in order to be able to run java programs?

1014