如下的50个关键字是Java语言的保留字:
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 |
关键字 goto
和 const
是保留的 C++ 关键字,但目前尚未在Java中使用。
如果它们出现在了Jav程序中,Java编译器能够识别它们,并生成更好的错误信息。
就像字面值100一样, true
, false
和null
不是关键字,就像数字100不能用作标识符一样,true
, false
和null
同样不能用作关键字。
Introduction to Java Programming Appendix A.