首页 > 其他 > 详细

英语笔记2

时间:2019-04-17 16:53:59      阅读:99      评论:0      收藏:0      [点我收藏+]

JAVA

Naming(Variable Names变量命名规则)

1.Variable names are case-sensitive. A variable‘s name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_". The convention, however, is to always begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it‘s technically legal to begin your variable‘s name with "_", this practice is discouraged. White space is not permitted.

变量名区分大小写,不建议使用_$。

2.Subsequent characters may be letters, digits, dollar signs, or underscore characters. Conventions (and common sense) apply to this rule as well. When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases it will also make your code self-documenting; fields named cadencespeed, and gear, for example, are much more intuitive than abbreviated versions, such as sc, and g. Also keep in mind that the name you choose must not be a keyword or reserved word.

建议使用单词全品而不是缩写

3.If the name you choose consists of only one word, spell that word in all lowercase letters. If it consists of more than one word, capitalize the first letter of each subsequent word. The names gearRatio and currentGear are prime examples of this convention. If your variable stores a constant value, such as static final int NUM_GEARS = 6, the convention changes slightly, capitalizing every letter and separating subsequent words with the underscore character. By convention, the underscore character is never used elsewhere.

多个单词的命名,第一个小写其他首字母大写。常量值的命令略有不同,每个单词都要大写而且单词之间通过“_”下划线分割。

Naming a Method(方法命名规则)

1.By convention, method names should be a verb in lowercase or a multi-word name that begins with a verb in lowercase.

  按照惯例,方法名应该是个动词小写。多个单词第一个也应该是动词小写

2.In multi-word names, the first letter of each of the second and following words should be capitalized

   多个单词命名,第二个和后面的每个单词的第一个字母都应该大写

英语笔记2

原文:https://www.cnblogs.com/jinliang374003909/p/10724286.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!