Search code examples
javanaming-conventions

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


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 mostly used to separate words, as blank spaces can't be used.


Solution

  • From the Java Language Specification on identifiers:

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