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 the difference between Array and Hash Table?

1042


What is the use of runnable interface?

1177


What is string length in java?

964


What are kinds of processors?

996


How many characters is 2 bytes?

1002


What is return code?

1020


What is the difference between static (class) method and instance method?

1090


What are thread safe functions?

959


What is a treeset class?

1020


What is a default constraint?

1078


What are advantages of exception handling in java?

1028


Why do we need singleton class?

1011


What does file separator do in java?

1024


What is Mutex (Mutual Exclusion Object) ?

1158


What is a numeric string?

1034