最近整理了Java核心基础技术的所有知识点,整理成一本详细的带图文的pdf电子书笔记。下面记录了一小部分笔记里边的知识,文末给出获取整本电子书地址。
访问控制权限其实最核心就是一点:只对需要的类可见。
Java中成员的访问权限共有四种,分别是 public 、protected 、default 、private ,它们的可见性如下:
在Java规范中,对非受查异常和受查异常的定义是这样的:
The unchecked exception classes are the run-time exception classes and the error classes.
The checked exception classes are all exception classes other than the unchecked exception classes. That is, the checked exception classes are Throwable and all its subclasses other than RuntimeException and its subclasses and Error and its subclasses.
也就是说,除了 RuntimeException 和其子类,以及 error 和其子类,其它的所有异常都是 checkedException 。
那么,按照这种逻辑关系,我们可以对 Throwable 及其子类进行归类分析
可以看到, Throwable 位于异常和错误的最顶层,我们查看 Throwable 类中发现它的方法和属性有很 多,我们只讨论其中几个比较常用的
// 返回抛出异常的详细信息 public string getMessage(); public string getLocalizedMessage(); //返回异常发生时的简要描述 public public String toString(); // 打印异常信息到标准输出流上 public void printStackTrace(); public void printStackTrace(PrintStream s); public void printStackTrace(PrintWriter s) // 记录栈帧的的当前状态 public synchronized Throwable fillInStackTrace();
整本笔记下载地址:
文章评论