官术网_书友最值得收藏!

2.9 Identifiers

These are the names you get to make up for classes, methods and variables like args and HelloWorld in the HelloWorld example. An identifier is any sequence of uppercase letters, lowercase letters, digits, $, and _ (underscore), except that it cannot start with a digit to avoid confusion with numbers. The set of “letters” in Java is much broader than in most other programming languages. Java letters include the symbols from most written languages used in the world today.

必須給類、方法和變量加上名字,例如args and HelloWorld in the HelloWorld example。標志符可以為任何大寫字母、小寫字母、阿拉伯數字、$和_(下畫線),但是不能以阿拉伯數字開頭,以防與數字混淆。

Here are some legal identifiers:

helloWorld $$$$$$ you_can_almost_make_a_sentence

_something x12345 $__$123

Here are some illegal identifiers:

123 x+y some***name no space 1floor

Some naming conventions (not required rules) used by many Java programmers are

(1)class names start with uppercase and capitalize embedded words - e.g. HelloWorld

(2)public methods and variables start with lowercase and capitalize embedded words-e.g. drawOval

(3)private and local variables are all lowercase, separating words with underscore-e.g. loop_index, input_value

(4)Although legal, the dollar sign “$” should not be used except in machine generated Java programs.

主站蜘蛛池模板: 壤塘县| 额济纳旗| 泗阳县| 隆子县| 黔东| 碌曲县| 盐边县| 吉木乃县| 和硕县| 平和县| 黎平县| 杭州市| 梅州市| 昌都县| 蓝田县| 宁武县| 荔波县| 金昌市| 准格尔旗| 宜良县| 航空| 金山区| 南漳县| 当阳市| 永济市| 手机| 娄底市| 周至县| 康平县| 武定县| 荔波县| 三原县| 望江县| 平昌县| 盐边县| 宁强县| 崇仁县| 墨江| 贺兰县| 铜陵市| 九寨沟县|