java List removeAll 慢

kuroniko / 2023-08-16 / 原文

 

之前 

odmComponentPlatformListCopy.removeAll(componentPlatformListCopy);

 

由于2个list都有100多万 非常慢  几个小时

 

改为

 

odmComponentPlatformListCopy.removeAll(new HashSet<>(componentPlatformListCopy));

 

几秒钟就完成了,list的泛型对象需要实现hashcode和equals方法