A main difference between a Set and a List is that the set admits no duplicates. So instead of List<Integer[]>
I am trying to create a Set<Integer[]>
such that no two elements are equal. But I am getting the following results when I read Set<Integer[]>
[0, 4, 5]
[3, 4, 1]
[4, 5, 0]
[0, 3, 6]
[1, 3, 4]
[1, 2, 7]
For my implementation, [0, 4, 5]
and [4, 5, 0]
are considered equal. Hence my question: Is there a way to override the equals method of Integer[]
so that the add
method of the set function can avoid admitting both [0, 4, 5]
and [4, 5, 0]
?