W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
關(guān)鍵詞是其含義由編程語(yǔ)言定義的詞。 Java關(guān)鍵字和保留字:
abstract class extends implements null strictfp true assert const false import package super try boolean continue final instanceof private switch void break default finally int protected synchronized volatile byte do float interface public this while case double for long return throw catch else goto native short throws char enum if new static transient
標(biāo)識(shí)符是程序員用來命名變量,方法,類或標(biāo)簽的單詞。關(guān)鍵字和保留字不能用作標(biāo)識(shí)符。標(biāo)識(shí)符必須以字母,美元符號(hào)($)或下劃線(_)開頭;后續(xù)字符可以是字母,美元符號(hào),下劃線或數(shù)字。
一些例子是:
foobar // legal Myclass // legal $a // legal 3_a // illegal: starts with a digit !theValue // illegal: bad 1st char
Java標(biāo)識(shí)符區(qū)分大小寫。例如, myValue
和 MyValue
是不同的標(biāo)識(shí)符。
標(biāo)識(shí)符用于類名,方法名和變量名。標(biāo)識(shí)符可以是大寫和小寫字母,數(shù)字或下劃線和美元符號(hào)字符的任何序列。標(biāo)識(shí)符不能以數(shù)字開頭。Java標(biāo)識(shí)符區(qū)分大小寫。以下代碼說明了有效標(biāo)識(shí)符的一些示例:
public class Main { public static void main(String[] argv) { int ATEST, count, i1, $Atest, this_is_a_test; } }
以下代碼顯示無效的變量名包括:
public class Main { public static void main(String[] argv){ int 2count, h-l, a/b, } }
如果嘗試編譯此代碼,您將收到以下錯(cuò)誤消息:
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: