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
What are multiple inheritances? Is it supported by java?
What is the method to expand and collapse nodes in a jtree?
What is charat java?
Can we override singleton class?
Can a final variable be initialized in constructor?
Explain about main thread in java?
What are different types of states exist for a thread?
What is final modifier?
What is meant by tab pans?
What is the base class in java from which all classes are derived?
Explain the difference between throw and throws in java?
How do you represent a space in regex java?
What is the default value of the local variables?
What does indexof mean?
What is Java Shutdown Hook?