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

  • SEARCH
  • Home
  • 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 4546920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:01:22+00:00 2026-05-21T16:01:22+00:00

I am reading Programming in Scala, and I don’t understand the following sentence (pdf

  • 0

I am reading Programming in Scala, and I don’t understand the following sentence (pdf p.112):

Each singleton object is implemented as an instance of a synthetic class referenced from a
static variable, so they have the same initialization semantics as Java statics.

Does this mean the if I have a singleton FooBar in scala, the compiler will create a class named FooBar$?

Also what does the author mean by “referenced from a static variable”? Is there a hidden static variable somewhere holding a reference to some FooBar$ class?

I appreciate any help here.

  • 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-21T16:01:22+00:00Added an answer on May 21, 2026 at 4:01 pm

    The chapter 31 of the same “Programming in Scala” is more precise:

    Java has no exact equivalent to a singleton object, but it does have static methods.

    The Scala translation of singleton objects uses a combination of static and instance methods. For every Scala singleton object, the compiler will create a Java class for the object with a dollar sign added to the end.
    For a singleton object named App, the compiler produces a Java class named App$.
    This class has all the methods and fields of the Scala singleton object.
    The Java class also has a single static field named MODULE$ to hold the one
    instance of the class that is created at run time.
    As a full example, suppose you compile the following singleton object:

    object App {
      def main(args: Array[String]) {
        println("Hello, world!")
      }
    }
    

    Scala will generate a Java App$ class with the following fields and methods:

    $ javap App$
    public final class App$ extends java.lang.Object
        implements scala.ScalaObject{
      public static final App$ MODULE$;
      public static {};
      public App$();
      public void main(java.lang.String[]);
      public int $tag();
    }
    

    That’s the translation for the general case.

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

Sidebar

Related Questions

Are there public instance variables anymore in Scala? I'm reading Programming in Scala ,
I'm reading through Programming in Scala. It says: You can redefine the behavior of
I'm reading a book on scala programming (the Programming in Scala), and I've got
Possible Duplicate: Which IDE for Scala 2.8? I'm learning Scala by reading 'Programming in
I'm reading the Programming in Scala book by the Scala Creator and I'm a
From reading parts of the Programming in Scala book, I realize that Scala can
I recently bought Programming Scala , and have been reading through it. The language
I am reading a programming from the ground up, if you don't know what
Since a week I'm reading Programming in Scala. The authors introduce elements of the
a theoretical question. After reading Armstrongs 'programming erlang' book I was wondering the following:

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.