Immutable Variables

In the following lesson, you will learn how to declare an immutable variable.

We'll cover the following

Immutable is defined as unchangeable and is precisely what an immutable variable is; unchangeable.

Immutable variables are basically like constants; once they are assigned a value, that value can never change.

Declaring an Immutable Variable

To declare an immutable variable, we use the val keyword. Let’s create a variable named message that is assigned a String value.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy