chapter_5_beginning_javabook

Right after the declaration of the variable the

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: 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 declared. The...
View Full Document

Ask a homework question - tutors are online