Back to Developer Roadmap

Variables & Constants

src/data/roadmaps/scala/content/variables--constants@-qLeSRC44_V-c8hoHyMqA.md

4.0983 B
Original Source

Variables & Constants

Variables are named storage locations that hold data, and their values can be changed during the program's execution. In Scala, variables are declared using the var keyword. On the other hand, constants are also named storage locations, but their values cannot be modified once they are assigned. Constants are declared using the val keyword in Scala, making them immutable. Choosing between var and val depends on whether you need to change the value of a data item during the program's runtime.

Visit the following resources to learn more: