Reputation: 8017
I have two files:
logic.scala and main.scala
logic.scala contains one class and main.scala have one class with method main (to run it). And I want to import a class from logic.scala and use this class to create object(s) and work with them.
How to import and compile it in proper way?
Upvotes: 35
Views: 56749
Reputation: 20627
logic.scala
codepackage logic class Logic{ def hello = "hello" }
main.scala
codepackage runtime import logic.Logic // import object Main extends Application{ println(new Logic hello) // instantiation and invocation }
scalac
scalac *.scala
scala
scala -cp . runtime.Main
Upvotes: 54