Why are Runtime Exceptions “unchecked” in Java?

前端 未结 3 2168
小蘑菇
小蘑菇 2021-01-02 15:14

Why does it make sense to have Runtime Exceptions UnChecked (as opposed to if they were Checked)?

3条回答
  •  情书的邮戳
    2021-01-02 15:40

    This simply means that the compiler will not force you to look for an exception, but you can still throw it at runtime. As one benefit, this allows you to throw new exceptions from your classes without requiring you to alter your interface, causing callers to change their code.

提交回复
热议问题