標籤:
官方說法:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html 為了方便我直接複製過來了,原文如下: Here‘s a list of keywords in the Java programming language. 下面是Java程式設計語言的關鍵字列表。 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. 關鍵字const和goto語句是保留的,雖然他們目前沒有使用。 true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs. true,false,和null看起來是關鍵字,但它們實際上是字面值;你不能用它們作為程式標識符。
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 |
存取控制
- private 私人的
- protected 受保護的
- public 公用的
類、方法、變數の修飾符
- abstract 聲明抽象
- class 類
- extends 擴允,繼承
- final 終極,不可改變的
- implements實現
- interface 介面
- native 本地
- new 新,建立
- static 靜態
- strictfp 嚴格,精準
- synchronized 線程,同步
- transient 短暫
- volatile 易失
- const
- assert
程式控制語句
- break 跳出迴圈
- continue 繼續
- return 返回
- do 運行
- while 迴圈
- if 如果
- else 反之
- for 迴圈
- instanceof 執行個體
- switch 開關
- case 返回開關裡的結果
- default 預設
- goto
錯誤處理
- catch 處理異常
- finally 有沒有異常都執行
- throw 拋出一個異常對象
- throws 聲明一個異常可能被拋出
- try 捕獲異常
包相關
- import 引入
- package 包
基本類型
- boolean 布爾型
- byte 位元組型
- char 字元型
- double 雙精確度,
- float 浮點
- int 整型
- long 長整型
- short 短整型
變數引用
- super 父類,超類
- this 本類
- void 無傳回值
- enum 枚舉類型
共有:3+15+13+5+2+8+4=50個關鍵字,全部是小寫 結論:
- const、goto 是關鍵字,雖然沒用,但不能拿來當變數名
- true、false、null 不是關鍵字,但也不能用來當變數名
- friendly、sizeof 不是關鍵字,可以用來當變數名
Java有多少個關鍵字