val in scala

In Scala, the keyword val is used to declare an immutable variable. Once a value is assigned to a val, it cannot be reassigned. Here's an example of how to use val in Scala:

val x: Int = 5

In this example, x is declared as a val with the type Int, and it is assigned the value of 5. Since x is a val, its value cannot be changed later in the program.