Questions tagged «multi-catch»

10
我可以在同一catch子句中捕获多个Java异常吗?
在Java中,我想做这样的事情: try { ... } catch (/* code to catch IllegalArgumentException, SecurityException, IllegalAccessException, and NoSuchFieldException at the same time */) { someCode(); } ...代替: try { ... } catch (IllegalArgumentException e) { someCode(); } catch (SecurityException e) { someCode(); } catch (IllegalAccessException e) { someCode(); } catch (NoSuchFieldException e) { …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.