我有这段代码可以比较两个列表是否具有相同的对象:
List<CcustoPrestadorOuImplDTO> implsNaConfig = configImplPermitida.getImplementos();
List<CcustoPrestadorOuImplDTO> implsNoApto = configuracaoImplementoDoApontamento.getImplementos();
Collections.sort(implsNaConfig, Comparator.comparing(o -> o.getCdCcusto()));
Collections.sort(implsNoApto, Comparator.comparing(o -> o.getCdCcusto()));
if ( implsNaConfig.equals(implsNoApto) ){
return true;
}
在调试中我有这种情况:
如您所见,两个列表都具有具有相同属性的相同对象。
但是比较两个列表是否相等的代码总是返回false。
我尝试使用 containsAll() 方法,但由于某种原因也返回 false。
我究竟做错了什么?