Java Throwable getSuppressed() 方法

2024年11月9日 | 阅读 1 分钟

Java Throwable 类的 getSuppressed() 方法用于返回为了传递该异常而抑制的所有异常的数组。如果没有抑制任何异常,则返回一个空数组。

语法

返回

用于传递该异常而抑制的异常的数组。

示例 1

输出

Caught inside Main:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ThrowableGetSuppressedExample1.main(ThrowableGetSuppressedExample1.java:19)