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
Which data type is class in java?
How do you generate random numbers in java?
What are features of java?
What are the states of thread in java?
What is array sorting in java?
What are different types of encoding?
How to change the priority of thread or how to set priority of thread?
How do you test a method for an exception using junit?
What is the difference between yield() and sleep()?
worst case complexities of Quick sort and Merge sort.
How many bits is a boolean?
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
What is the inheritance?
Which sorting algorithm is in place?
What is polymorphism and what are the types of it?