<分区>
我有以下数组列表
List<Long> ids = new ArrayList<Long>();
List<Long> empIds = new ArrayList<Long>();
现在我需要比较这两个数组并检查 ids 中的任何值是否存在于 empIds 中。如果是,我需要以 boolean 值 true 退出。我通过以下方式完成了此操作。
for (Long id : ids) {
if (empIds.contains(id)) {
checker = true;
break;
}
}
但这需要很多时间。有人可以帮我优化一下吗?