0 votes
in Scala Constructs by
What are different types of Scala variables?

1 Answer

0 votes
by
It is well known that variables are merely reserved memory locations for storing values. In Scala, variables are mainly of two types:  

Mutable Variables: These are variables whose value is capable of changing and the var keyword is used to declare these variables.

Syntax:  

 var Variable_name: Data_type = "value";

Example:

 var Company: String = "InterviewBit”;

Immutable Variables: These are variables whose value is not capable of changing and the val keyword is used to declare these variables.

Syntax:

 var Variable_name: Data_type = "value";

Example:

 val Company: String = "InterviewBit";
...