Why are empty collections of different type equal?

后端 未结 2 636
不思量自难忘°
不思量自难忘° 2021-02-11 12:10

What is mechanism below that makes equal different types?

import static org.testng.Assert.assertEquals;
@Test
public void whyThisIsEq         


        
2条回答
  •  萌比男神i
    2021-02-11 13:11

    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.

提交回复
热议问题