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...

suppose in a class there is a code like this:
{
Set hs=new Hashset();
hs.add(new Emp("kathy",1000));
hs.add(new Emp("kathy",2000));
}
how can u avoid the above code in your class as set won't
allow duplicate objects?

Answer Posted / harish

This can achieved by overriding equals and hashCode method

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is api data?

945


What is a methodologist?

993


Why are the destructors for base class and derived class called in reverse order when the program exits

2127


What is an argument java?

919


What is Mutex (Mutual Exclusion Object) ?

1079


Can a final method be overloaded?

886


Which java version is latest?

962


what is difference between equals and ==?

997


What is a flag value?

954


Can vector have duplicates in java?

885


What is string manipulation?

948


What are the two types of exceptions in java? Which are the differences between them?

1036


Explain the difference between private, public, package and protected in java?

992


What is computer compiler?

936


What is the method in java?

1021