Why are empty collections of different type equal?

后端 未结 3 2192
攒了一身酷
攒了一身酷 2021-02-11 12:29

What is mechanism below that makes equal different types?

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


        
3条回答
  •  眼角桃花
    2021-02-11 13:17

    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.

提交回复
热议问题