Category : Java | Sub Category : | By Prasad Bonam Last updated: 2020-09-18 09:16:34 Viewed : 460
package
com.prabonam.main
object Runner { //
def main(args:
Array[String]): Unit = {
println("Hello
Scala!")
}
}
OutPut:
Hello Scala!
Explanation:
·
object Runner: object is the keyword which is used to create
the objects. Objects are the instance of a class. Here “Runner” is the name of the object.
·
def main(args: Array[String]): def is the keyword in Scala which is used to define
the function and “main” is the name of Main Method. args: Array[String] are used for the
command line arguments.
·
println(“Hello
Scala!”): printtewtln
is a method in Scala which is used to display the
Output on console.
Unit
is a subtype of
scala.AnyVal. There is only one value of typtest dsiplay link Unit
, ()
,
and it is not represented by any object in the underlying runtime system. A
method with return type Unit
is analogous to a Java method which is declared void
.
final abstract class Unit private extends
AnyVal {
override def getClass(): Class[Unit]
= null
}