I am in a bit of confusion. Suppose I have class A and some List<A>
in some other class B.
So, because I am using a list, duplicates are allowed. Because duplicates are allowed (that means no comparison needed), do I have to override method equals() and hashCode() in class A?
So the emphasis here is on List (duplicates allowed - no need for comparison).
And I should override these 2 methods when I am using Set (duplicates NOT allowed - we need to define how objects will be compared)? (99% sure this is correct answer, just want to check it and make sure I got 100% correct answer for both: List and Set)
Note: I did not find answer on stack because no one asked excact same thing with using lists and duplicates allowed.