Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training

It is about TreeSet and TreeMap

if a class A overrides equals() and compare() methods .

Then on adding A to Set or Map which method will be preferred.



Also if HashSet or HashMap is there then which method will preferred.

When you say which method, do you mean which of the two methods of equals() and compare() ?

If I understand your question correctly, there isn't a matter of a 'preference' here. It would use equals() to find out if that object has already been in the list, and compare() to find out the location it should be added to.

ExamLab © 2008 - 2024