This preview shows page 1. Sign up to view the full content.
Unformatted text preview: emory.
Right after the declaration of the variable, the contents of the four bytes are unspecified.
After an assignment statement like
integer_from_keyboard = keyboard.nextInt() ; is executed, the four bytes are given values that represent the number that was typed in
from the keyboard.
The illustration in Figure 5-1 shows the general principle according to which memory is reserved for variables. The compiler may, however, optimize the use of memory if it
finds out that it can save memory. 102 Chapter 5: Variables and other basic elements in Java programs This line is not actually part of the program. This is
a comment line that gives documentary information to
the reader of the program. A double slash // marks the
beginning of a comment line. The compiler ignores the
double slash and the text that follows it on the same
line. As was explained in Chapter 2, we need
to have these lines in those programs which
read data from the keyboard. // Game.java Here two integer variables are
View Full Document
- Winter '14