Answer Posted / Prakash Kumar Rathaur
In Scala, val and var are used to declare variables. The main difference lies in their immutability: val declares a constant that cannot be reassigned, while var can be reassigned. Once assigned, the value of a val remains unchanged throughout its lifetime, whereas the value of a var may change multiple times.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers