When should I use the dollar symbol ($) in a variable name?

后端 未结 6 1662
情歌与酒
情歌与酒 2020-12-17 09:10

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

6条回答
  •  星月不相逢
    2020-12-17 09:54

    Theoretically you can use dollar sign in variable names, but it's strongly discouraged because that symbol is used internally by the compiler(e.g. inner or anonymous classes's name).

    Please refer to two related questions on the stackoverflow: What is the meaning of $ in a variable name? and Java class name containing dollar sign fails to compile if an inner class is present

提交回复
热议问题