小宗学编程(三)Java学习入门

小宗学编程(三)Java学习入门


Java学习入门



分享兴趣,传播快乐,增长见闻,留下美好!亲爱的您,这里是LearningYard新学苑。今天小编为大家带来“Java学习入门”,欢迎您的访问。

Share interests, spread happiness, increase knowledge, and leave good news! Dear you, this is the new LearningYard Academy. Today, Xiaobian brings you "Introduction to Java Learning", welcome your visit.



小宗学编程(三)Java学习入门


Java学习入门——标识符


标识符定义

Java对各种变量、方法、类等要素命名时使用的字符序列称作标识符。

比如:类名、变量名、方法名、接口名、包名......

(实用小技巧:凡是可以自己起名字的地方都叫标识符。)


The sequence of characters that Java uses to name various variables, methods, classes and other elements is called an identifier.

For example: class name, variable name, method name, interface name, package name...

(Practical tip: Anywhere you can name yourself is an identifier.)





小宗学编程(三)Java学习入门



标识符的命名规则

1.由26个英文字母大小写,0-9,或$组成。

2.数字不可以开头。

3.不可以使用关键字和保留字,但可以包含关键字和保留字。

4.java中严格区分大小写,长度无限制。

5.标识符不能包含空格。

(如果不遵守标识符的命名规则,编译不会通过!需要大家严格遵守。)

Identifier Naming Rules

1. Consists of 26 uppercase and lowercase English letters, 0-9, or $.

2. Numbers cannot start.

3. Keywords and reserved words cannot be used, but keywords and reserved words can be included.

4. Java is strictly case-sensitive, and the length is unlimited.

5. Identifiers cannot contain spaces.

(If the naming rules of identifiers are not followed, the compilation will not pass! Everyone needs to strictly abide by them.)


小宗学编程(三)Java学习入门

Java中的名称命名规范

1.包名:多单词组成时,所有字母都小写(xxxyyyzzz)。

2.类名、接口名:多单词组成时,所有单词的首字母大写(XxxYyyZzz)。

3.变量名、方法名:多单词组成时,第一个单词首字母小写,第二个单词开始首字母大写(xxxYyyZzz)。

4.常量名:所有字母都大写。多单词时每个单词用下划线连接(XXX_YYY_ZZZ)。

(如果不遵守以上规范编译可以通过!但是建议大家遵守)


Naming conventions in Java

1. Package name: When composed of multiple words, all letters are lowercase (xxxyyyzzz).

2. Class name, interface name: When composed of multiple words, the first letter of all words is capitalized (XxxYyyZzz).

3. Variable name, method name: When composed of multiple words, the first letter of the first word is lowercase, and the second word is uppercase (xxxYyyZzz).

4. Constant names: All letters are capitalized. When there are multiple words, each word is connected with an underscore (XXX_YYY_ZZZ).

(If you do not comply with the above specifications, the compilation can pass! But it is recommended that you follow)


注意事项

1.在命名标识符时,为了提高阅读性,要尽量有意义,所谓“见名知意”

2.java采用unicode字符集,因此标识符也可以使用汉字声明,但是不建议使用。

Precautions

1. When naming identifiers, in order to improve readability, try to be as meaningful as possible.

2.java uses the unicode character set, so identifiers can also be declared using Chinese characters, but it is not recommended.




今天的分享就到这里了。如果您对今天的文章有独特的想法,欢迎给我们留言,让我们相约明天,祝您今天过得开心快乐!

That's it for today's sharing. If you have a unique idea about today’s article, Welcome to leave us a message. Let us meet tomorrow, I wish you a happy day today!





END

翻译:来自Googl翻译

本文由LearningYard新学苑原创,欢迎关注,带你一起长知识。


排版:谢宗佑

文字:谢宗佑

审核:李小雪

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章