We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule 5. 【推荐】如果变量值仅有有限的可选值,用枚举类来定义常量
尤其是变量还希望带有名称之外的延伸属性时,如下例:
//WRONG public String MONDAY = "MONDAY"; public int MONDAY_SEQ = 1;
//RIGHT public enum SeasonEnum { SPRING(1), SUMMER(2), AUTUMN(3), WINTER(4); int seq; SeasonEnum(int seq) { this.seq = seq; } } 默认的default的访问域是不能跨包的,如果枚举类放在基础包下的话,seq的访问就无法生效了。所以感觉这里写的不够严谨。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Rule 5. 【推荐】如果变量值仅有有限的可选值,用枚举类来定义常量
尤其是变量还希望带有名称之外的延伸属性时,如下例:
//WRONG
public String MONDAY = "MONDAY";
public int MONDAY_SEQ = 1;
//RIGHT
public enum SeasonEnum {
SPRING(1), SUMMER(2), AUTUMN(3), WINTER(4);
int seq;
SeasonEnum(int seq) { this.seq = seq; }
}
默认的default的访问域是不能跨包的,如果枚举类放在基础包下的话,seq的访问就无法生效了。所以感觉这里写的不够严谨。
The text was updated successfully, but these errors were encountered: