In Eclipse plugin, I could create scala Object, APP and class. But what’s the difference among these 3. Basically, for object, I implement def main(…), then I could run it. But in class, it seems it is similar to normal Java class, but what’s the meaning scala APP, it creates a object which extends APP. What’s this meant for?
Share
In the JVM, the starting point of the application is a static method
main(String[] args), in some class given to the JVM.In scala there is no static methods, the equivalent is to put a method in an object (as opposed to class). Putting your main method in a class will not work, it is the same as not marking the method static in java.
Appis a helper that allows not to write the main method, and put the code directly in the object body.does the same thing as
(arguments can be used in doStuff under the name
args)