July 2017
Intermediate to advanced
796 pages
18h 55m
English
Before entering into the depth of OOP features, first, we need to know details about the different types of variables and data types in Scala. To declare a variable in Scala, you need to use var or val keywords. The formal syntax of declaring a variable in Scala is as follows:
val or var VariableName : DataType = Initial_Value
For example, let's see how can we declare two variables whose data types are explicitly specified as follows:
var myVar : Int = 50val myVal : String = "Hello World! I've started learning Scala."
You can even just declare a variable without specifying the DataType. For example, let's see how to declare a variable using val or var, as follows:
var myVar = 50val myVal = "Hello World! I've started learning ...
Read now
Unlock full access