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
Is java an open source?
Can we have this () and super () together?
What is a concrete classes? Is Java object class is concrete class?
When will we use them?
What is finally block?
Explain the difference between jvm and jre?
Can we initialize the final blank variable?
Whats the difference between notify() and notifyall()?
What is the byte order of byte buffer?
What is the difference between final, finally and finalize() in java?
Can we extend a class with private constructor?
What is the difference between static method and instance method in Java?
What is the synonym of framework?
List out benefits of object oriented programming language?
What is complexity and its types?