令牌“else"上的语法错误 [英] Syntax error on token `else`
本文介绍了令牌“else"上的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对编码很陌生,我不断收到这个错误,我真的需要帮助.这是我的代码:
I am very new to coding and I keep getting this error I really need help with it. This is my code:
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){
if (stack.getItem() == halo.TitaniumHelmet || stack.getItem() == halo.TitaniumChestplate || stack.getItem() == halo.TitaniumBoots) {
return "halo:textures/models/armor/Titanium1.png";
}
if (stack.getItem() == halo.TitaniumLeggings); {
return "halo:textures/models/armor/Titanium_layar_2.png";
} else { //<------ Syntax error on token "else", delete this token
return null;
}
推荐答案
这里条件后面多了一个分号:
Here there is an extra semicolon after the condition:
if (stack.getItem() == halo.TitaniumLeggings);
删除它.语句将是这样的:
Remove it. Statement will be like this:
if (stack.getItem() == halo.TitaniumLeggings) { ... }
这篇关于令牌“else"上的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文