空指针异常错误,即使在尝试捕获null时也是如此

时间:2013-02-14 00:20:31

标签: java null nullpointerexception integer break

我正在使用Bukkit的API,但我会从中删除一些代码,因为它不是API(因为它没有在我正在做的事情中引入)。所以,我一直收到'Null Pointer Exception',在搜索Google之后,我似乎无法将任何修复与我的代码联系起来。所以这是我的代码:

Integer tier = null;
    for(Integer i = 1; i <= 5;) 
    {
        if (p.hasPermission("flyp.fly." + i.toString())){
            tier = i - 1;
            break;
        }
        i++;
    }

if(tier == null) 
    {
            p.sendMessage(ChatColor.RED + "You lack the permission to do this!");
            return true;
    }

当使用此代码时,(当我使用'/ fly on'时,事件)我得到'空指针异常',并且它指向'if(tier == null)'行。最后,我正在清理“旧”代码,这部分是我的朋友写的,我似乎无法联系-_-。

感谢您的帮助, AhellHound

0 个答案:

没有答案