Difference between using App trait and main method in scala

Viewed 29743

What is the difference between

object Application extends App {
   println("Hello World")
}

and

object Application {
    def main(args: Array[String]): Unit = {
        println("Hello World");
    }
}
3 Answers

App trait is implemented using the [[DelayedInit]] functionality, which means that fields of the object will not have been initialized before the main method has been executed.

Related