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 the difference between Array and Hash Table?
What is the use of runnable interface?
What is string length in java?
What are kinds of processors?
How many characters is 2 bytes?
What is return code?
What is the difference between static (class) method and instance method?
What are thread safe functions?
What is a treeset class?
What is a default constraint?
What are advantages of exception handling in java?
Why do we need singleton class?
What does file separator do in java?
What is Mutex (Mutual Exclusion Object) ?
What is a numeric string?