Jui*_*iCe 7 java naming-conventions member-variables
我想知道有人会如何命名以首字母开头而不是单词的成员字段.
public class MyClass {
// I know this is how it is for a member field with words.
private String myString;
// What about this String? It is representing the term "RV Scale" which is
// short for "Reclose Volts Scale."
private String RVScale;
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用private String recloseVoltsScale
,但我宁愿保留RVScale.如果有人知道如果它的应该是rVScale
或RVScale
或别的东西,我会很感激的信息.
编辑:
那么,像这样的成员领域呢......
private int RV;
Run Code Online (Sandbox Code Playgroud)
根据java命名约定,成员字段应该以混合大小写开头,所以它应该是rvScale
,并且成员字段RV
应该是这样的private int rv;
使用正确的字母大小写是遵循命名约定的关键:
小写是指单词中的所有字母都不大写(例如 while、if、mypackage)。
大写是指单词中的所有字母都大写。当名称中有两个以上的单词时,请使用下划线分隔它们(例如,MAX_HOURS、FIRST_DAY_OF_WEEK)。
CamelCase(也称为 Upper CamelCase)是指每个新单词都以大写字母开头(例如 CamelCase、CustomerAccount、PlayingCard)。
混合大小写(也称为 Lower CamelCase)与 CamelCase 相同,只是名称的第一个字母为小写(例如,hasChildren、customerFirstName、customerLastName)。
归档时间: |
|
查看次数: |
924 次 |
最近记录: |