Defining Values and Variables
Let’s look at some syntax . We’ll start by creating a variable:
val language: String = "Scala"
We’ve defined a variable as a String and assigned to it the value of “Scala.” I say “variable,” but we’ve actually created an immutable value rather than a variable. The val keyword creates a constant, and language cannot be modified from this point on. Immutability is a key theme you’ll see again and again in Scala.
If we will want to modify language later, we can use var instead of val. We can then reassign it if we need to.
var language: String = "Java"
language = "Scala" ...