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
How many threads can I run java?
How many types of exception can occur in a java program?
Can we convert stringbuilder to string in java?
For class CFoo { }; what default methods will the compiler generate for you>?
What is merge sort in java?
why java uses class level type casting ?
What is a ternary operator in java? What is an interface?
Where is java located?
Is null a keyword in java?
Explain the scope of a variable.
Is empty string in java?
What happens when I use / and % with a negative numerator?
What is math floor in java?
What is the static import?
Implementations of set interface?