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 7728585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:45:21+00:00 2026-06-01T05:45:21+00:00

From the An Overview of the Scala Programming Language, Second Edition : // Scala

  • 0

From the An Overview of the Scala Programming Language, Second Edition:

// Scala
object PrintOptions {
    def main(args: Array[String]): Unit = {
        System.out.println("Options selected:")
        for (val arg <- args)
            if (arg.startsWith("-"))
                System.out.println(" " + arg.substring(1))
    }
}

In the example above, the Scala program invokes methods startsWith
and substring of String, which is a class defined in Java. It
also accesses the static out field of the Java class System, and
invokes its (overloaded) println method. This is possible even
though Scala does not have a concept of static class members. In fact,
every Java class is seen in Scala as two entities, a class
containing all dynamic members and a singleton object, containing all
static members.

I understand translation of Scala’s companion objects into Java bytecode, but I am not sure what exactly does it means bold text in upper blockquote “is seen in Scala” for opposite example (from Java to Scala).

Does it mean that Java classes with static members are actually converted or just interpreted as two entities in Scala? Or both of my assumptions are wrong?

  • 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-06-01T05:45:23+00:00Added an answer on June 1, 2026 at 5:45 am

    I think you might be blinded by Java assumptions. Consider this simple snippet of code:

    X.Y()
    

    The means that the method Y is being called on the object X, or on some other object which X was implicitly converted into.

    Maybe that doesn’t look surprising, or you don’t see anything amiss with that, so let’s state explicitly a consequence: X will NEVER be a class. You don’t invoke methods on classes, period.

    Naturally, that presents a serious interoperability problem with Java regarding static members, and that’s why it is stated that static members of a Java class X will be “seen” as a singleton object: because, otherwise, you’ll never be able to use them.

    Note that Scala’s singleton objects are true objects — they are instances of singleton classes. Java classes with static members will not give origin to single objects, though. In practice, this means that this line:

    val x = X
    

    will work if X is a Scala singleton object, but won’t work if it is a Java class with static members.

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

Sidebar

Related Questions

Quick overview: trying to build a gallery with a string from $_GET ('foo'), which
I have a overview page containing a list with some links from which multiple
Overview From time to time in jQuery I want to check a condition of
It seems from the MSDN overview that the only change to ADO.Net in .Net
From the Collections Framework Overview : Collections that do not support modification operations (such
Overview I'm in the process of porting a simple utility app over from C#
Overview: I am trying to avoid a race condition with accessing an IndexedDB from
Overview of My Situation: My task is to read strings from a file, and
I'm looking for a high level overview of how one goes from an AST
Overview I am writing a Ruby program that uses data from mysql queries to

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.