標(biāo)識(shí)符:
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的綏芬河網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!Java對(duì)各種變量、方法和類等要素命名時(shí)使用的字符序列稱為標(biāo)識(shí)符
凡是自己可以起名字的地方都叫標(biāo)識(shí)符
定義合法標(biāo)識(shí)符的規(guī)則:
由26個(gè)英文字母大小寫,0-9,_或$組成
數(shù)字不可以開頭
不可以使用關(guān)鍵字和保留字,但是能包括關(guān)鍵字和保留字
Java中嚴(yán)格區(qū)分大小寫,長度無限制
標(biāo)識(shí)符不能包括空格
取名盡量做到“見名知意”
關(guān)于使用中文,Oracle 官網(wǎng)給出的文檔是這樣描述的:
An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter. Identifier: IdentifierChars but not a Keyword or BooleanLiteral or NullLiteral IdentifierChars: JavaLetter {JavaLetterOrDigit} JavaLetter: any Unicode character that is a "Java letter" JavaLetterOrDigit: any Unicode character that is a "Java letter-or-digit" A "Java letter" is a character for which the method Character.isJavaIdentifierStart(int) returns true. A "Java letter-or-digit" is a character for which the method Character.isJavaIdentifierPart(int) returns true. The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\|u0041-\|u005a), and a-z (\u0061-\|u007a), and, for historical reasons, the ASCII underscore (_, or \|u005f) and dollar sign (\$, or \|u0024). The $ sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems. The "Java digits" include the ASCII digits 0-9 (\|u0030-\|u0039). Letters and digits may be drawn from the entire Unicode character set, which supports most writing scripts in use in the world today, including the large sets for Chinese, Japanese, and Korean. This allows programmers to use identifiers in their programs that are written in their native languages.