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
What is a two-pass assembler?
Is alive method in java?
What is the collections api in java programming?
What are the differences between processes and threads?
What is the difference between sleep and wait in java?
What are the six ways to use this keyword?
How do you create an array in java?
Which eclipse is best for java?
What does it mean to flush a file?
Can you call a method in a method?
Which is easier netbeans or eclipse?
Explain the difference between abstract classes and interfaces in java?
What do you understand by copy constructor in java?
Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.
What is string args [] in java?