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 an anonymous class in java?

1082


what is object slice?

2061


What is the similarity between dynamic binding and linking?

1103


What is var keyword ?

1167


What is gc()?

1042


Can we declare main () method as non static?

954


Does java runtime require a license?

1040


What is the difference between dom and sax parser in java?

956


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

1031


How to change value in arraylist java?

1151


How do you square a number in java?

1041


How many digits can a float hold?

994


What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?

1100


Can we assign integer value to char in java?

1007


How to print an arraylist in java?

1058