在码代码的过程中,需要我们对异常进行处理,如图所示:

IDEA异常处理和代码块包装

快捷方式一(光标移到该代码行,Alt+Enter),可以异常外抛出,也可以try-catch:

IDEA异常处理和代码块包装

选择Add Exception to method signature:

IDEA异常处理和代码块包装

选择Surround with try/catch:

IDEA异常处理和代码块包装

快捷方式二(光标移到该代码行,或者选中该行代码,Ctrl+Alt+T):

IDEA异常处理和代码块包装

相关文章:

  • 2021-11-20
  • 2021-05-24
  • 2021-09-04
  • 2021-11-06
  • 2021-05-17
  • 2021-12-01
  • 2021-10-01
猜你喜欢
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案