Uncatchable ChuckNorrisException

前端 未结 17 2219
时光取名叫无心
时光取名叫无心 2020-12-02 03:34

Is it possible to construct a snippet of code in Java that would make a hypothetical java.lang.ChuckNorrisException uncatchable?

Thoughts that came to m

17条回答
  •  被撕碎了的回忆
    2020-12-02 04:12

    Any exception you throw has to extend Throwable, so it can be always caught. So answer is no.

    If you want to make it difficult to handle, you can override methods getCause(), getMessage(), getStackTrace(), toString() to throw another java.lang.ChuckNorrisException.

提交回复
热议问题