Figure 5 1 the variables of program gamejava in a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the variable integer_from_keyboard looks like this if individual bits are shown. Figure 5-1. The variables of program 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 as long 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.

Ask a homework question - tutors are online