Variables, Values, Declarations, and Assignments

Variables, Values, declarations, and assignments are building blocks of computer programming.

Variables: In a computer program, a variable is a word that can hold a value. It is made up of letters and numbers.

Examples of Variables
name
tomsAge
candybarPrice
skyIsBlue
shirtColor
Values: A value is a piece of data or information. You store values in variables.
Examples of values
"Tom Dunn"
22
0.65
true
green
Declarations: In a computer program, you must declare a variable before you can do anything with it. A declaration starts with a data type, then the variable, then a semicolon (;)
Examples of Declarations
String name;
int tomsAge;
double candybarPrice;
boolean skyIsBlue;
Color shirtColor
Assignments: In a computer program, you use an assignment to give a variable a value. An assignment starts with a variable name, then an equals sign (=), then a value, then a semicolon (;)
Examples of Assignments
name = "Tom Dunn";
tomsAge = 22;
candybarPrice = 0.65;
skyIsBlue = true;
shirtColor = green;

Back to Data Types     Forward to Graphics