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
How do you sort objects in java?
What is the super void?
What is array and arraylist in java?
What are the advantages and disadvantages of object cloning?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
What is widening and narrowing in java? Discuss with an example.
when you will synchronize a piece of your code? : Java thread
What is string [] java?
What is the difference between a checked and an unchecked exception?
What is singleton service?
What technique is carried out to find out if a particular string is empty?
What is difference in between java class and bean?
What is the difference between preemptive scheduling and time slicing in java programming?
What do you understand by access specifiers in Java?
What string is utf8?