shortcut to add throws declaration in Intellij Idea

When a piece of code needs error handling, IntelliJ underlines it with red. Set your pointer on that piece of code and press ALT+ENTER. IntelliJ should now give you the choice to either surround it with try/catch, add a catch clause, or to add a throws declaration.

In your case: click the underlined code → ALT+ENTER → Add Exception to Method Signature

IntelliJ also has a shortcut to place your cursor on the next error or warning: F2. This – especially in combination with ALT+ENTER – is quite useful.

原文地址:https://www.cnblogs.com/kakaisgood/p/11899042.html