在 Java 中目前一共有53个关键字,我们按照使用频率及面试频率依次分析关键字使用场景及衍生的原理。
1. 访问权限修饰符
| public | 公共的 | 可跨包 |
|---|---|---|
| protected | 受保护的 | 当前包内可用 |
| private | 私有的 | 当前类可用 |
2. 定义类。接口,抽象类及实现接口,继承类的关键字,实例化对象
| class | ||
|---|---|---|
| interface | ||
| abstract | ||
| implemenst | ||
| extends | ||
| new |
3. 修饰方法,类,属性和变量
| static | ||
|---|---|---|
| final | https://www.cnblogs.com/lwbqqyumidi/p/3513047.html | |
| super | ||
| this | ||
| native | ||
| synchronized | 具体内容在多线程章节中 | |
| transient | ||
| volatile | 具体内容在多线程章节中 |
其他
| enum | 枚举 | https://www.cnblogs.com/hyl8218/p/5088287.html ,需重点关注enum 原理分析 |
|---|---|---|
| assert | 断言 |
