Skip to content

Variables

trekitch edited this page Feb 20, 2017 · 12 revisions

#What is a Variable

A variable is a location in memory that that can hold data that may vary. A variable can be anything from a a number to a string of words. An example of this can be seen in the Strings chapter where we made different literal strings. Numbers can also be variables. In fact, numbers are the main type of variables used when programming. This is especially true when you have a program that will do a lot of math.

#Data Types for Variables

A variable can hold many different values. To hold all these values a variable has many different data types. Below is a table of of the data types for a variable.

Data Type Description
byte Byte-length integer
short Short integer
int Integer
long long integer
float Single-precision floating point
double Double-precision floating point
char A single character
boolean A Boolean value(true or false)
Clone this wiki locally