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
What is api data?
What is a methodologist?
Why are the destructors for base class and derived class called in reverse order when the program exits
What is an argument java?
What is Mutex (Mutual Exclusion Object) ?
Can a final method be overloaded?
Which java version is latest?
what is difference between equals and ==?
What is a flag value?
Can vector have duplicates in java?
What is string manipulation?
What are the two types of exceptions in java? Which are the differences between them?
Explain the difference between private, public, package and protected in java?
What is computer compiler?
What is the method in java?