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
Can you extend singleton class?
What are the differences between heap and stack memory?
Who developed java?
How to declare objects of a class ?
When is the garbage collection used in Java?
What is ‘has a’’ relationship in java?
Is node a data type in java?
Explain abstract class in java?
placement papaers of spring computing technology
Is null == null in java?
What are the differences between forwarding () method and sendredirect() methods?
What is polymorphism java example?
Are functions objects in java?
What does a za z0 9 mean?
What is the purpose of main function in java?