比较两个集合元素是否相同?

menuSearches.sort(Comparator.comparing(String::hashCode));

先对集合中的元素进行排序,排序后,转成String类型,然后使用equals进行比较

猜你喜欢

转载自www.cnblogs.com/qingmuchuanqi48/p/12013966.html