Why AbstractCollection does not implement equals()?

前端 未结 3 473
时光说笑
时光说笑 2021-01-18 05:49

Did you know that :

Map m1 = new HashMap();
Map m2 = new HashMap();
Sys         


        
3条回答
  •  感动是毒
    2021-01-18 06:25

    Per the contract of Collection#equals(), there is no general-purpose equals() methods for Collections, and thus AbstractCollection cannot provide one.

    Note that HashMap$Values is neither a Set nor a List, thus the quandary and in a sense the reason it does not support equals().

提交回复
热议问题