2

I am new to scala ,and worked with java previosly.On studying i found that we can create a singleton object like given below

object Hello{
    def main(a:Array[String]){
        println("hello user")
    }
}

If Scala uses JVM then why the scala programe created by singleton object doesnt require a static main method?

I know its a very basic question but i am a beginner. and also if anybody can suggest me some docs online to study scala. Thanks in advance.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
deogratias
  • 472
  • 2
  • 8
  • 23
  • possible duplicate of [Scala: defining main method that can be used by 'java'](http://stackoverflow.com/questions/1737714/scala-defining-main-method-that-can-be-used-by-java) – Chris Martin Jul 19 '14 at 06:45

1 Answers1

2

Methods of singleton objects get translated into static methods (among other stuff)strong text. So you actually do have the equivalent of a static main method.

Have a look at the generated class files and you will see.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348