NullPointerException thrown after field is check if it is null
问题 I am developing a plugin for Bukkit (http://bukkit.org) and after verifying that it is not null, it gives me a NullPointerException at the 2nd line String description = getConfig().getString("core.commands."+cmd+".description"); if (!(description.isEmpty())) getCommand(cmd).setDescription(description); else getLogger().warning("NO description assigned to: " + cmd); description = null; 回答1: isEmpty() is different from null check. isEmpty() checks is String is empty String (which means "" ).