Disable warning in IntelliJ for one line

后端 未结 7 1117
庸人自扰
庸人自扰 2020-12-15 02:03

I have a Java code line where IntelliJ displays a warning. How do I silence the warning in that particular line, without affecting warnings displayed in other lines?

7条回答
  •  感情败类
    2020-12-15 02:45

    Expanding upon Ryan Stewart's answer, in IntelliJ, use Alt+Enter, then select the first sub-menu, then the last item: Suppress for statement.

    enter image description here

    Update

    Using IntelliJ IDEA 13, I noticed an additional menu item: "Suppress for statement with comment". This will use the IntelliJ style //noinspection unchecked. If you select "Suppress for statement", IntelliJ will insert this text: @SuppressWarnings("unchecked").

提交回复
热议问题