Java 1不==1,布尔问题

Java 1不==1,布尔问题,java,boolean,Java,Boolean,我是疯了还是怎么了,还是我需要更多的睡眠。。。请再给我一副眼睛好吗 boolean slotTypeMatch = false; System.out.println("waiType: " + waiType); if (waiType.equals("W")){ } else if(waiType.equals("A")){ itemFilename = MyServer.armorMap.get(waiId).getFilename(); System.out.print

我是疯了还是怎么了,还是我需要更多的睡眠。。。请再给我一副眼睛好吗

boolean slotTypeMatch = false;
System.out.println("waiType: " + waiType);
if (waiType.equals("W")){

} else if(waiType.equals("A")){
    itemFilename = MyServer.armorMap.get(waiId).getFilename();
    System.out.println("endContainerSlot: " + endContainerSlot + ", getSlot: " + MyServer.weaponMap.get(waiId).getSlot());
    if (endContainerSlot == MyServer.armorMap.get(waiId).getSlot()){
        System.out.println("WHY DONT I MAKE IT HERE!!!!");
        slotTypeMatch = true;
    }
}
System.out.println("itemFilename: " + itemFilename);
System.out.println("slotTypeMatch: " + slotTypeMatch);
if (slotTypeMatch){
    //not making it here, I must be going insane
这是我的控制台输出。。。我一辈子都搞不懂这个

waiType: A 
endContainerSlot: 1, getSlot: 1
itemFilename: images/armor/armor_tunic.png 
slotTypeMatch: false
编辑它们都是int

int endContainerSlot - com.jayavon.game.server.MyCommandHandler.run()
int com.jayavon.game.actualgame.Armor.getSlot()

您输出了
MyServer.weaponMap
,但您正在将
endContainerSlot
MyServer.armorMap
进行比较。 我认为您想要与
武器地图进行比较,或者您正在进行正确的比较,但在输出中看到了错误的地图

System.out.println("endContainerSlot: " + endContainerSlot + ", getSlot: " + MyServer.weaponMap.get(waiId).getSlot());
if (endContainerSlot == MyServer.armorMap.get(waiId).getSlot()){
    System.out.println("WHY DONT I MAKE IT HERE!!!!");
    slotTypeMatch = true;
}

你在这里比较不同的地图,armorMap和weaponMap,我认为这是你的问题…

MyServer.armorMap
&
MyServer.weaponMap
是不同的。我认为你应该更新你的代码,睡一觉。:)


它们是同一类型的吗?是的,对不起,它们都是int endContainerSlot和getSlot的数据类型是什么?你在比较什么类型的数据类型?它们都是int,我已经编辑过了,很抱歉省略了显而易见的内容。谢谢,一百万,我正式上床睡觉了。很抱歉浪费你们的时间。。。当它让我在9分钟内接受的时候,那就请不要再浪费你的时间了,谢谢百万观众简单而伟大+1:)
if (endContainerSlot == MyServer.weaponMap.get(waiId).getSlot()){...}