Why are two empty ArrayLists with different generic types equal?

Look the doc for the equals() method of ArrayList

Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal.

Since there are no elements, all the conditions satisfied and hence true.

If you add elements to the both list (atleast one in each), to see the desired output.

Leave a Comment