Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6583913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:28:15+00:00 2026-05-25T16:28:15+00:00

Recently I read that the sign $ is allowed in Java variable names, but

  • 0

Recently I read that the sign $ is allowed in Java variable names, but has a special meaning. Unfortunately it isn’t mentioned what this special meaning is.

Therefore I ask here: What is the special meaning of $ in variable names in Java?

Here is the exact quote from

Java: An Introduction to Problem Solving and Programming

from Walter Savitch:

Java does allow the dollar sign symbol $ to appear in an identifier,
but these identifiers have a special meaning, so you should not use
the $ symbol in your identifiers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:28:15+00:00Added an answer on May 25, 2026 at 4:28 pm

    $ is used internally by the compiler to decorate certain names. Wikipedia gives the following example:

    public class foo {
        class bar {
            public int x;
        }
    
        public void zark () {
            Object f = new Object () {
                public String toString() {
                    return "hello";
                }
            };
        }
    }
    

    Compiling this program will produce three .class files:

    • foo.class, containing the main (outer) class foo
    • foo$bar.class,
      containing the named inner class foo.bar
    • foo$1.class, containing the
      anonymous inner class (local to method foo.zark)

    All of these class names are valid (as $ symbols are permitted in the JVM specification).

    In a similar vein, javac uses $ in some automatically-generated variable names: for example, this$0 et al are used for the implicit this references from the inner classes to their outer classes.

    Finally, the JLS recommends the following:

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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently read that Java now sports initialisation blocks like the following: class C
I recently read (and unfortunately forgot where), that the best way to write operator=
I recently read that getters/setters are evil and I have to say it makes
I recently read somewhere that writing a regexp to match an email address, taking
I recently read in a presentation on Scribd that Facebook had benchmarked a variety
I recently read through Code Complete, and it recommends that I create a project
Recently i read an article is about prevent brute-force attack. It said that automatically
I recently read that in StringWriter and StringReader are used for writing and reading
I read recently that the C# and CLI standards define different ways to handle
Recently read in a article on dotnetpearls.com here saying that static ctors take a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.