2013-04-29 94 views
-2

我会疯了吗?或者我需要更多的睡眠...可以annyone提供第二套眼睛吗?1不== 1,布尔问题

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 endContainerSlot - com.jayavon.game.server.MyCommandHandler.run() 
int com.jayavon.game.actualgame.Armor.getSlot() 
+0

他们是同一类型吗? – Blender 2013-04-29 04:49:24

+0

对不起,他们都是int – KisnardOnline 2013-04-29 04:50:10

+0

endContainerSlot和getSlot的数据类型是什么? – 2013-04-29 04:50:30

回答

6

您输出MyServer.weaponMap,但您正在比较endContainerSlotMyServer.armorMap。 我想你想要比较weaponMap或者你正在做正确的比较,但在输出中查看错误的地图。

+0

AHHHHH万分感谢,我正式上床睡觉。对不起,浪费你的家伙时间...将在9分钟内接受,当它让我,然后床 – KisnardOnline 2013-04-29 04:52:58

+0

晚上然后;) – Excelcius 2013-04-29 04:53:53

3
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 VS weaponMap,我认为这是你的问题...

+0

对不起,浪费你的时间,谢谢百万 – KisnardOnline 2013-04-29 04:53:16

3

MyServer.armorMap & MyServer.weaponMap是不同的。我认为你应该更新你的代码并进行一些睡眠。 :)

if (endContainerSlot == MyServer.weaponMap.get(waiId).getSlot()){...} 
+0

看起来简单和伟大+1 :) – 2013-04-29 04:54:16