Why different type empty collections are equal (TestNG)

  • A+

What is mechanism below that makes equal different types?

   @Test     public void whyThisIsEqual() {         assertEquals(new HashSet<>(), new ArrayList<>());     } 


import static org.testng.Assert.assertEquals; 


The assertEquals(Collection<?> actual, Collection<?> expected) documentation says:

Asserts that two collections contain the same elements in the same order. If they do not, an AssertionError is thrown.

Thus the content of the collections will be compared which, in case both the collections are empty, are equal.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: