Labels

Monday, April 11, 2022

Variables in Scala (Class -27)

 variable is named a reference to a memory location. The location stores the data that is used by the program.

 Collect the data and keep them in a Container. There are 2 types of Collections:

a)      Mutable Collections

b)      Immutable Collections

a)      Mutable Variables are those that allow us to change its value any time in the code.

   e.g.: var keyword

b)      Immutable Variables that are made immutable are read-only variables in Scala. This means their value remains unchanged throughout the program. E.g.: val keyword.

 In both the above cases, you can assign value to a variable with / without datatype.



No comments:

Post a Comment