An excerpt from wiki
Scala is a general-purpose programming language providing support for both object-oriented programming and functional programming. The language has a strong static type system. Designed to be concise, many of Scala’s design decisions are aimed to address criticisms of Java.
It is executed in a JVM.
.scala
file compiles to executablebyte code
by scala compiler. Byte Code is executed in JVM on different Operating systems
Two types of variables in scala
val
, can not be re-assigned. It is equivalent to Java final
keyword. object Variables {
def main(args: Array[String]): Unit = {
println("Hello World");
/*
* Immuatable Variables
*/
val definedInteger : Int = 3;
definedInteger = 5 ; // gives compilation error, reassignement of val
}
}
var
. It can be reassigned. /*
* Mutable Variables
*/
var mutableInteger : Int = 3;
mutableInteger = 5 // reassignement is allowed