Java关键字

1 Java关键字

根据官网说明,java有如下关键字。

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html


Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and gotoare reserved, even though they are not currently used. truefalse, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.

abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while
*   not used
**   added in 1.2
***   added in 1.4
****   added in 5.0

需要说明的是,true、false和null不是关键字,但也不能当标识符用。

2 关键字分类

关键字可以分为以下几类:

http://www.java3z.com/cwbwebhome/article/article8/81253.html?id=2799

 3 关键字的另一种分类方式

关键字也可分为以下几类:

3.1 常见关键字

3.1.1 类相关

class 定义一个类
interface 定义一个接口
extends 扩展一个类或接口
abstract 描述一个抽象类
implements 实现一个接口 
public、protected、private 类、方法、成员变量的权限控制
this 指向类自身
super 指向父类
final 不可被继承、不可被修改
static 全局、静态
const 保留字、不可被修改
 

3.1.2 其他

try、catch、throw、throws、finally、assert 异常控制 
void、byte、boolean、int、char、long、float、double、enum 数据类型
break、continue、if、else、switch、case、default、for、do、while、return 流程控制 
goto 保留字
import、package 包
new 
 

3.2 不常见关键字

native 本地
strictfp 严格,精准
synchronized 线程,同步
transient 短暂
volatile 易失

 


 
全文完。 重剑无锋,大巧不工。
原文地址:https://www.cnblogs.com/yanyichao/p/3752482.html