A variable is a chunk of computer memory that contains a value. The name of a variable is an identifier that refers to the variable.
A variable's data type
determines the size of the chunk and the way that the bits in the chunk are
interpreted. If the data type of a variable is int
, the
variable holds a 32-bit signed integer. If the data type of a
variable is double
, the variable holds a 64-bit signed
floating-point number.
As a program runs, a variable's value may change, but a variable's data
type never changes. Thus, the value of a variable named script
,
with type int
, could be 8
at one time and 9
at
another, but the value of script
could never be a number with type
double
, such as 8.5
.