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 java an open source?

973


Can we have this () and super () together?

1043


What is a concrete classes? Is Java object class is concrete class?

984


When will we use them?

1052


What is finally block?

1057


Explain the difference between jvm and jre?

1040


Can we initialize the final blank variable?

1090


Whats the difference between notify() and notifyall()?

1041


What is the byte order of byte buffer?

1024


What is the difference between final, finally and finalize() in java?

1159


Can we extend a class with private constructor?

1010


What is the difference between static method and instance method in Java?

1209


What is the synonym of framework?

1001


List out benefits of object oriented programming language?

897


What is complexity and its types?

1033