10. Hello World – first Scala program !!! object HelloWorld { def main(args: Array[String]) { println("Hello World") } } object HelloWorld e xtends Application { // no need of main method println("Hello World") } Output: Hello World
12. Variables Scala has two types of variables var & val Var – read write Val – read only Type inference val i=23 // inferred to int val str = “string” // inferred to int scala> val array: Array[String] = new Array(5) array: Array[String] = Array(null, null, null, null, null) scala> array = new Array(2) <console>:5: error: reassignment to val array = new Array(2)