| Contact PSVM (Q & A) | Notes Below Audio | [toc] [prev] Slide 8 of 18 [next] |
|
|
| 1, 2, 3, 4, 5, 6, 7, [8 (top)], 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, [Lab] |
|
Notes for Slide 08 Java will not allow you to attempt to get the value of an int variable until you put a value into it. Notice that this is different than a String variable which has a value of null. With a String variable, you are allowed to check if the value is null. With an int variable, however, you are not allowed to do anything with it until you put a number into to. You are not even allowed to check to see if the variable is empty. The example program above on the left shows using an input statement to place a number into the guess variable. The erroneous program above on the right shows a second statement that is not acceptable Java because the guess variable would be empty when the second statement runs. 1, 2, 3, 4, 5, 6, 7, [8 (top)], 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, [Lab] |