将int []与一次Integer进行比较 [英] Compare int[] with once Integer
问题描述
我有的表[]
。我和每个用户进行循环操作:
I have table of int[]
. I have for loop with every user and I do:
int[] ids = (values)
for (User user : listAfterProcessing) {
if (user.getId().equals(ids)) { ... }
}
他们没有工作,虽然用户ID在这个表中...
感谢您的帮助:)
They didnt work, Although the user id is in this table... Thanks for help :)
推荐答案
您正在检查 getId()
的结果是否等于整个数组 ids
,默认情况下是与数组的哈希码的比较。
You are checking whether the result of getId()
equals the entire array ids
, which is by default a comparison to the array's hashcode.
根据这个问题的答案:如何将int []转换为List< Integer>在Java?
According to an answer in this question: How to convert int[] into List<Integer> in Java?
没有快速的转换方法。
there is no quick way to convert.
我在答案的第一个版本中建议的Arrays.asList()解决方案在这里不起作用,抱歉。
The solution with Arrays.asList(), which I suggested in the first version of my answer, doesn't work here, sorry.
这篇关于将int []与一次Integer进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!