gpt4 book ai didi

java - 查找列表是否包含相同的数据?

转载 作者:太空宇宙 更新时间:2023-11-04 12:04:38 25 4
gpt4 key购买 nike

在这里,我想知道 list.cust.getComponentIdentification() 值是否包含相同的值,然后我想选择该值。

for(CustomizableMenus cust : ra.getAction().getCustomizablemenu()){

cust.getComponentId();
cust.getComponentIdentification();
cust.getComponentName();
cust.getComponentState();
custList.add(cust);
}

如果用户具有相同的componentIdentification,那么我想找到相应的组件标识。

最佳答案

据我了解,您想要查找列表中的某些内容是否与用户拥有的内容相同。

假装有一个对象“user”,你可以这样做:

User user = new User();
for (CustomizableMenus cust : ra.getAction().getCustomizablemenu()){
if (user.getComponentIdentification() == cust.getComponentIdentification()) {
// do whatever you need with it.
// you might also add a break here.
}
}

如果这不完全是您所需要的,请告诉我,以便我改进我的答案。

关于java - 查找列表是否包含相同的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40527462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com