The Variables in Scala are mainly of two types :
Mutable Variables :* We Declare
Mutable Variables by using the
var keyword.
* The values in the
Mutable Variables
support Changes
Syntax:
var Variable_name: Data_type = "value"; ​
Example :
var Company: String = "FreeTimeLearn”; ​
Immutable Variables :* We declare
Immutable Variables using the
val keyword.
* The values in
Immutable Variables
do not support changes.
Syntax :
var Variable_name: Data_type = "value"; ​
Example :
val Company: String = "FreeTimeLearn";​