更新时间:2021-08-07 21:45:26
Intellij-Jetbrains是一个非常聪明的IDE,它本身就是你解决许多问题的方法。
Intellij-Jetbrains is very clever IDE and itself suggests you way for solving many problems.
请看下面的截图。它建议你删除此警告的五种方法:
Look at screenshot below. It suggests your five ways for removing this warning:
1)添加断言值!= null
;
2)用替换return语句返回值!= null? value.toString():null;
3)环绕
if (value != null) {
return value.toString();
}
4)通过添加评论来抑制对此特定陈述的检查:
4) suppress inspection for this particular statement by adding commentary:
//noinspection ConstantConditions
return value.toString();
5)至少添加,因为之前的@ochi建议使用 @SuppressWarnings( ConstantConditions)
注释,可用于方法或整个类。
5) add at least, as earlier @ochi suggested use @SuppressWarnings("ConstantConditions")
annotation which can be used for method or for whole class.
要调用此上下文菜单,请使用快捷键 Alt + Enter
(我认为它们适用于所有操作系统)。
To invoke this context menu use shortcut keys Alt+Enter
(I think they are common for all OS).