Java基礎之關鍵字

來源:互聯網
上載者:User
關鍵字 作者:Matrix-stopno   

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





  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的關鍵字


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.