In Java, a program starts from a class's static main method. But in Scala, it starts from a object's main method.
Does anyone know the rationality of designing like this?
Scala also provide a trait called App
, which can replace main
method if an object extends this trait. Does anyone have ideas about which one (App
or main
) is the preferred way?
Thanks!
Scala has singleton objects instead of java static members. So main method of object is analogue of java static main method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With