在Java编程中有一些英文单词是不能用来作为对象或者变量的名字。这些单词被称为保留字(reserved),是因为它们已经被Java语法用作关键字。
例如,如果你尝试新建一个类,并使用一个 保留字来命名该类,如下代码:
// you can't use finally as it's a reserved word!
class finally {
public static void main(String[] args) {
//class code..
}
}因为命名不合法,所以这段代码是不会进行编译的,你只会得到如下报错信息:
<identifier> expected
下面表格列出了所有的保留字:
| abstract | assert | boolean | break | byte | case |
| catch | char | class | const* | continue | default |
| double | do | else | enum | extends | false |
| final | finally | float | for | goto* | if |
| implements | import | instanceof | int | interface | long |
| native | new | null | package | private | protected |
| public | return | short | static | strictfp | super |
| switch | synchronized | this | throw | throws | transient |
| true | try | void | volatile | while |
原文地址:http://java.about.com/od/javasyntax/a/reservedwords.htm
2万+

被折叠的 条评论
为什么被折叠?



