程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA編程入門知識 >> Java的關鍵字與保留字小結

Java的關鍵字與保留字小結

編輯:JAVA編程入門知識
Java 關鍵字列表 (依字母排序 共51組):
abstract, assert,boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum,extends, final, finally, float, for, if, implements, import, instanceof, int, interface, long, native, new, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, try, void, volatile, while
Java 保留字列表 (依字母排序 共14組) : Java保留字是指現有Java版本尚未使用 但以後版本可能會作為關鍵字使用。
byValue, cast, false, future, generic, inner, operator, outer, rest, true, var , goto ,const,null

呵呵,不管別的,來幾條題目先,作對了你牛^_^

  1, which of the following are keywords or reserved words in java?
  a) if b)then c)goto d)while e)case f)sizeof

  2, which of the following are java key words?
  a)double b)Switch c)then d)instanceof

  3, which of these are key words in java?
  a) default b)NULL c)String d)throws e)long f)true

  答案來了 1,acde 2,ad 3,adef 作對了嗎^_^

  解釋來了 1,then和sizeof都不是java的關鍵字,熟悉c或者c++,寫慣了asp的高手就要小心喽。

  2,所有的關鍵字都是小寫的,所以Switch不是關鍵字。instanceof看上去像方法名,但其實是關鍵字;

  3,大寫的NULL不是java語言的關鍵字。String是java語言的一個封裝類的類名,也不是關鍵字。

  再來點系統的:

  正確識別java語言的關鍵字(keyword)和保留字(reserved word)是十分重要的。Java的關鍵字對java的編譯器有特殊的意義,他們用來表示一種數據類型,或者表示程序的結構等。保留字是為java預留的關鍵字,他們雖然現在沒有作為關鍵字,但在以後的升級版本中有可能作為關鍵字。

  關鍵字列表

  abstract boolean break byte case
  catch char class continue default
  do double else extends false
  final finally float for if
  implements import instanceof int interface
  long native new null package
  private protected public return short
  static super switch synchronized this
  throw throws transient true try
  void volatile while
  
  保留字
  const,goto

  注意點

  識別java語言的關鍵字,不要和其他語言如c/c++的關鍵字混淆。

  const和goto是java的保留字。
  所有的關鍵字都是小寫
  friendly,sizeof不是java的關鍵字
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved