[英]Check if an exception is a checked exception at runtime
這是在運行時檢查異常是否為已檢查異常的正確方法嗎?
public boolean isChecked(final Throwable e) {
return !(RuntimeException.class.isAssignableFrom(e.getClass())
|| Error.class.isAssignableFrom(e.getClass()));
}
我想像下面這樣的一些條件就足夠了
return !(e instanceof RuntimeException || e instanceof Error);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.