Checked Exception是编译时还是运行时? [英] Checked Exception is compile time or runtime?

查看:118
本文介绍了Checked Exception是编译时还是运行时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到Checked异常是由编译器检查的,但仅限于运行时。

I read about Checked exception that it is checked by compiler , but its runtime only.

是否正确?

如果正确,那么如何?

推荐答案

在编译时会检查经检查的异常以确保您正在处理它们,通过捕获它们或声明包含方法引发例外。

Checked exceptions are checked at compile time to ensure you are handling them, either by catching them or declaring the containing method throws the exception.

在运行时,选中的对象之间没有区别和未经检查的异常:JVM对它们的处理相同。因此,检查性纯粹是一个编译时概念。

At runtime, there is no distinction between checked and unchecked exceptions: they are treated identically by the JVM. So "checked-ness" is purely a compile-time concept.

这篇关于Checked Exception是编译时还是运行时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆