问题:Java中goto是关键字吗?
回答:goto是Java的关键字。goto目前被作为Java的关键字保留起来。goto不能作为标识符。(下方官方文档里明确指出了goto和const是关键字,已经用红色标出!)
问题:什么是标识符?
回答:标识符是用来识别物件的名称。例如,变量名,函数名,标签名等等。
问题:什么是Java的保留字?
回答:保留字就是被Java保留的标识符,所以用户不能使用保留字作为一个标识符。中文维基百科中指出保留字有时也叫关键字。而英文维基百科并没有给出此定义。本人觉得还是以英文维基百科为主!所以我们通俗理解Java中的保留字就是:目前被保留起来,还未使用,但是在以后版本里的Java中可能会被使用的Java关键字。如,const和goto。
来自官方的关键字汇总整理:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
Java Language Keywords
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 goto
are reserved, even though they are not currently used. true
, false
, 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 |