| Free tutorials for Java, Eclipse and Web programming |
Scala has two types of variables.
The functional programming style of Scala emphasis the usage of val variables.
Scala is a strongly typed language, e.g. each variable has a specific type. The type declaration is optional; if no type is defined during declaration then the variable will get the type of the initial assigned value. This is called "type inference".
Create a scala project "de.vogella.scala.variables" and try the following code.
object VariablesTest extends Application {
val firstName = "Lars"
val lastName = "Vogel"
var test = "changable"
println(firstName)
}