What is the difference between "app" and "app $" in Intellij?

I am using Intellij

to develop a program Scala

. When clicked, run

it displays two apps: HelloWorld

and HelloWorld$

:
enter image description here

What's the difference between the two apps?

+3


source to share


1 answer


For jvm

HelloWorld$

is the singleton class HelloWorld

.

Scala generates a class ObjectName$

for every object ObjectName

.

It also creates static methods in this class, which looks like this:



public static void main(String[] args) {
  MODULE$.main(args);
}

      

From, java

you can either get an instance of an object ObjectName

using a static field ObjectName$.MODULE$

, or call static proxy methods on ObjectName$

.

+4


source







All Articles