use*_*462 -2 java syntax-error
我对编码很新,我不断收到这个错误,我真的需要帮助.这是我的代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
更改
if (stack.getItem() == halo.TitaniumLeggings); {
Run Code Online (Sandbox Code Playgroud)
至
if (stack.getItem() == halo.TitaniumLeggings) {
Run Code Online (Sandbox Code Playgroud)
这很糟糕,因为
if (stack.getItem() == halo.TitaniumLeggings); {
//do stuff...
}
Run Code Online (Sandbox Code Playgroud)
相当于
if (stack.getItem() == halo.TitaniumLeggings) {
}
//The above EMPTY block is only executed when the
//if evaluates to true. The below is ALWAYS executed.
{
//do stuff
}
Run Code Online (Sandbox Code Playgroud)
这很糟糕.