因为IllegalAccessException
不是RuntimeException
(即为例外),而IllegalStateException
为(即为不受限制的例外)。
阅读更多信息: java.lang.RuntimeException and java.lang.Exception
http://download.oracle.com
The first kind of exception is the checked exception. These are exceptional conditions that a well-written application should anticipate and recover from. For example, suppose an application prompts a user for an input file name, then opens the file by passing the name to the constructor for java.io.FileReader. Normally, the user provides the name of an existing, readable file, so the construction of the FileReader object succeeds, and the execution of the application proceeds normally. But sometimes the user supplies the name of a nonexistent file, and the constructor throws java.io.FileNotFoundException. A well-written program will catch this exception and notify the user of the mistake, possibly prompting for a corrected file name.
Checked exceptions are subject to the Catch or Specify Requirement. All exceptions are checked exceptions, except for those indicated by Error, RuntimeException, and their subclasses.
第二类例外是错误。 这些是申请之外的特殊条件,申请通常不能预期或收回。 例如,假设申请成功开启了输入档案,但由于硬件或系统故障而无法阅读档案。 失败的读本将 throw。 申请可以选择追索这一例外情况,以便向使用者通报问题,但也可能使方案具有印制笔迹和出走的意义。
www.un.org/Depts/DGACM/index_spanish.htm 误差不受要求或具体要求限制。 错误是Error及其子类指出的例外情况。
第三类例外是临时例外。 这些是申请内部的特殊条件,申请通常不能预期或收回。 通常表明方案拟定方面的弊端,如逻辑错误或不当使用预报工具。 例如,审议此前描述的申请,将档案名称提交给建筑商,以便存档。 如果逻辑错误导致无法向建筑商出售,则建筑商将“Null” 。 申请可以满足这一例外,但消除造成例外的弊端可能更有意义。
www.un.org/Depts/DGACM/index_spanish.htm 停职例外情况不受要求限制。 停职例外是RuntimeException及其子类所示。