在IDEA里面按住​​alt+insert​​可以快速生成 try-catch或者 throws 异常

如下:

IDEA选中代码生成try-catch块_java


但是如果你遇到的是下面这样的代码,​​alt+insert​​就显得有点繁琐了

IDEA选中代码生成try-catch块_代码生成_02


使用​​ctrl+alt+t​​ 快速将选中的代码生成指定的代码块!

IDEA选中代码生成try-catch块_代码块_03