将int []与一次Integer进行比较 [英] Compare int[] with once Integer

查看:123
本文介绍了将int []与一次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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆