Values and Reference Variables

Learn about the concept of directly and indirectly storing a value in a variable.

Storing values in variables

There are two ways that a variable can store its value in memory. We could think of these ways as direct and indirect. This might sound strange, but let’s use an analogy to explain.

The variables that directly store their data are like boxes. When we create them, we can think of them as a box that has the name of the variable stuck to it with a label. We can store the value inside the box and look in the box later to see what value is in there. Variables that store their values like this are called value variables:

Get hands-on with 1200+ tech skills courses.