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 / mushtaq hussain
by implementing equals and toHashCode method in emp Class
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
how to write a program for sending mails between client and server
How are observer and observable used in java programming?
What does \ mean in regex?
What is callable java?
What is the significance of listiterator?
What is a heavyweight component?
Write a java program to count the number of words present in a string?
What if constructor is protected in java?
What are the different ways to handle exceptions?
What exactly is a .class file?
What are the two ways to create a thread?
What is illegal identifier in java?
When is the garbage collection used in Java?
how we can make a read-only class in java?
Where is stringbuffer stored?