# Variables

A variable is kind of like a named box that holds something.

Here is a quick example in Java:

boolean isRobotOn = false;

To create a variable, you need 4 things:

  • You need a type, a type tells us what that "something" is. In this case our type is a boolean which stores either a true or false.
  • You need a name, which in this case is isRobotOn, you will use this name to refrence the variable later.
  • You need an equals sign, this is how we tell Java that we want to assign a variable to a value.
  • And lastly, you need a value, which in this case is false.

# Common Types in Robot Programming and Their Values

Type Value
int Whole numbers (such as 1, 2, -3, etc.)
double Numbers with a decimal (such as 1.234)
boolean Can be true or false

More information on booleans is available at Control Flow.
More information on types is available at Types.
For more information of variables, consider checking out the W3 Schools Java Tutorial.