我应该何时在变量名中使用美元符号($)? [英] When should I use the dollar symbol ($) in a variable name?

查看:661
本文介绍了我应该何时在变量名中使用美元符号($)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美元符号($)是用于命名变量的有效字符,例如 String superSecretFormula $; ,但是当我们谈论命名约定时,我应该何时使用此符号?

The dollar symbol ($) is a valid character to name a variable, e.g. String superSecretFormula$;, but when we're talking about naming conventions, when should I use this symbol?

例如,下划线最常用于分隔单词,因为不允许使用空格。

Underscore for example is most used to separate words, as blank spaces are not allowed.

推荐答案

来自标识符的Java语言规范


$ 字符只能用于机械生成的源代码,或者很少用于访问旧系统上预先存在的名称。

The $ character should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.

这篇关于我应该何时在变量名中使用美元符号($)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆