关键字throws

throws关键字,用于声明一个方法可能抛出的异常

1
2
3
public void test() throws AppException,SQLException,NumberFormatException {
//....
}

throws跟在方法的括号后面,可以声明多个异常,以逗号分隔。

test()方法内可能抛出如上三种一场,但开发者没有处理完,调用者必须进行处理。如果处理完则不需要声明。

  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2021 Silver Shaded
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信