ArrayList
already have support for this, with the equals
method. Quoting the docs
... In other words, two lists are defined to be equal if they contain the same elements in the same order.
It does require you to properly implement equals
in your MyData
class.
Edit
You have updated the question stating that the lists could have different orders. In that case, sort your list first, and then apply equals.