设置或选取状态变量有何要求

2025-06-02 21:54:08

1、设置变量不能是关键字:例如ab衡痕贤伎stractassertbooleanbreakbytecasecatchcharclassconstco荏鱿胫协ntinuedefaultdodoubleelseenumextendsfinalfinallyfloatforgotoifimplementsimportinstance ofintinterfacelongnativenew packageprivateprotectedpublicreturnstrictfpshortstaticsuperswitchsynchronizedthisthrowthrowstransienttryvoidvolatilewhile

2、jdk7以后可以用中文作为变量名,但是不推荐使用

3、按照阿里的编码规范,变量首字母小写,驼峰规则例如 order userName

4、可以使用_$符号 如 order_id $_systemTime_$

5、选取变量一般是通过获取变量的方法来访问变量,对象.get变量();如果是静态方法,类名.方法。例如获取一个0.2的小数

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢