Why different type empty collections are equal (TestNG)

  • A+
Category:Languages

What is mechanism below that makes equal different types?

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

EDIT:

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.

Comment

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