Variable Data Types

Programming languages use variables to store data that the program uses.
In Java we have specific variable types to hold certain kinds of data.

Here is a list of the data types available in Java:

Name Description
byte Byte-length integer – stores a tiny integer value.
short Short integer – store a small integer value.
int Integer – store a regular integer value.
long Long integer – store a massive integer value.
float Stores rational (decimal) numbers.
double Stores large rational (decimal) numbers
char Stores a single character
boolean A boolean value (true or false).

When using these variable types in Java, we declare the type but putting the name shown above first and then giving our variable its own name.


int myNumber = 8;

This creates a variable of type integer called “myNumber” and give the variable the value of 8.

Note the naming of the variable. You will see that it begins with a lower case letter with the second word beginning with an upper case letter. This is called “camel case” and should be used to name all Java variables.

In our programming we will also use another data type called “String” which stores text. This is not a simple data type like the variable listed above but a more intelligent object which allows us to format, compare and change the data stored in it.