Unformatted text preview: the variable
integer_from_keyboard looks like this if individual bits
are shown. Figure 5-1. The variables of program Game.java in a computer’s main memory. 5.1 Integer variables (int, short, long, byte, char) 105 In addition to variables of type int, Java has other types of integer variables. These
variables are sometimes called integral types. Type long is another integer type. Variables
of type long occupy 8 bytes (64 bits) of memory. They are thus longer integer variables
than variables of type int. If we declared the variables of program Game.java as
long integer_from_keyboard ;
one_larger_integer ; the program would work correctly with much larger numbers as it does now.
A third integer variable type is short which is a 2-byte, 16-bit, variable. This type
may be useful when your program uses only integer values that are smaller than 32,767. If
you need to store very many such values, you can save some memory by using type short
instead of type int. In small programs, though, there is no need to use...
View Full Document
This document was uploaded on 01/20/2014.
- Winter '14