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
Differences between C and Java?
What does null mean in java?
Differences between external iteration and internal iteration?
Difference between arraylist and hashset in java?
What is the file extension for java?
Where can i get Latest SUN Certification Dumps and what are the Sun Certification Codes that are available, Im new to JAVA, so please gimme info as i need to write J2EE - Core Java Certification
Is c better than java?
What is mean by collections in java?
Is null false in java?
Why do we need singleton?
worst case complexities of Quick sort and Merge sort.
Does variable declaration allocate memory?
How do you sort data in java?
Explain how to force the garbage collection in java.
Can a main method be overloaded?