Lets try our first Scala Program
Object name: MyFirstProgram.scala
In scala , Object is a singleton class. Meaning, Only one object is created for that class.
Method 1:
object MyFirstProgram{
def main()={
println("Hellow world!!!")
}
}
Method 2:
object MyFirstProgram extends App{
println("Hellow world!!!")
}
Similar to java MAIN method, in scala APP is the entry point to the program.
How to run this?
First Compile the code
> scalac MyFirstProgram.scala
Next Execute the code
> scala MyFirstProgram
Object name: MyFirstProgram.scala
In scala , Object is a singleton class. Meaning, Only one object is created for that class.
Method 1:
object MyFirstProgram{
def main()={
println("Hellow world!!!")
}
}
Method 2:
object MyFirstProgram extends App{
println("Hellow world!!!")
}
Similar to java MAIN method, in scala APP is the entry point to the program.
How to run this?
First Compile the code
> scalac MyFirstProgram.scala
Next Execute the code
> scala MyFirstProgram
No comments:
Post a Comment