Classnotes | JAVA01 | RecentChanges | Preferences There are other variable types that were not covered last time. Many of these types are rarely used, but they are all worth mentionning:
byte
byte can be used for integer numbers that range from -128 to 127. This is a useful data type when you do not need very large integers as it takes up much less space than a normal integer.
byte escapeKey = 27;
short
short can be used for integers that are smaller in size than the int type. A short integer can range from -36,768 to 36,767.
short roomNumber = 222;
long
long can be used to store integers that are too big for the int type to hold.
long atoms;
double
double is to float what long is to int. Using double, you can store floating point numbers that are much larger (or have more significant digits) than normal float. Using float, you can typically only store numbers with 38 digits. double can store as many as 324 digits.
double pi;
double is often much more useful than float, and in practice you will likely see it used more often.
Assigning Values to Variables
Last time, we saw that you can assign values to variables using the '=' (equals) sign.
pi = 3.1415;
you can also assign values from one variable to another variable: