Isn't an unchecked exception that is caught in a try block a checked exception in Java?

后端 未结 3 1614
南旧
南旧 2021-02-08 23:39

I was told that in Java, unchecked exceptions can be caught in a try block, but if it\'s caught, isn\'t it called a checked exception?

3条回答
  •  爱一瞬间的悲伤
    2021-02-08 23:59

    I think the distinction is that the compiler will flag uncaught checked exceptions and methods that throw checked exceptions but don't declare them in the method signature at compile time.

    Unchecked exceptions don't require declaration or catching, but neither are prohibited. The compiler just doesn't identify them as errors.

提交回复
热议问题