Editor warns me that an Object may produce a NPE in caught NullPointerException
已回答
Now, this isn't a serious problem, but why does the editor warn me that this
May produce a NPE?
String item = null;
Scanner scanner = new Scanner(System.in);
if(scanner.nextInt == 1)
{
item = "weapon";
}
try
{ /*Warning \/\/\/ here */
if(item.equals("weapon"))
{
//things....
}
}
catch(NullPointerException e)
{
e.printStackTrace();
}
请先登录再写评论。
Hi. I have raised a ticket for this issue, please follow:
https://youtrack.jetbrains.com/issue/IDEA-196866