Skip to content

Boxes with names

Read · 1 of 4

A variable is a named box

int apples = 5; makes a box called apples that holds whole numbers (int), and puts 5 in it.

Later you can read what's in the box, or put something new in it with =. The box keeps only the latest value.