7) Suppose there is Student class like
class student {
int age;
string name;
}
We want to store these objects in a HashMap. Do we need to
override any methods in Student class? If any which ones
and why? what if i just override equals or just hashcode?
what will be the results in both the cases?
Answer Posted / krishna
There is no need to override equals() and hashCode() methods. But if we want to eliminate duplicate objects in the HashMap, you should override both the methods. Either one is not enough.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is ternary operator in java?
Why does java doesnt suuport unsigned values?
what is synchronization and why is it important? : Java thread
How to sort an array from smallest to largest java?
How to perform bubble sort in java?
Is namespace same as package in java?
Can we create a constructor in abstract class?
Which eclipse is best for java?
Why is it important to initialize a variable?
Can we sort set in java?
What is the difference between static (class) method and instance method?
What is collection sort in java?
What is the difference between quicksort & mergesort? When should they be used? What is their running time?
How do you escape a string?
What happens if we override private method?