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

Is upper case in java?

1009


Write a program to calculate factorial in java?

1052


How do you join strings in java?

1112


Is alive and join method in java?

1263


Why is string buffer better than string ?

1197


What is final access modifier in java?

1211


What is a java list?

1157


What are the advantages of java over C++?

1250


Explain the polymorphism principle?

1076


What is meant by polymorphism?

1075


What is the main use of generics in java?

1074


Why we override equals() method?

1082


Can we override static methods in java?

1122


Is the empty set a singleton?

1029


Difference between static and dynamic class loading.

1183