June 2025
Intermediate to advanced
1093 pages
33h 24m
English
We have seen in several places that a new variable was introduced. In Listing 8.1, for example, it was this:
int upTo = 0;
This introduces a new variable—it declares it. First, its type is specified—here, int—and then the name under which the variable will be used—here, upTo. Done. But what about the equals sign = and what stands to its right? That is the initialization, and it is optional in this form of declaration. I have already discussed the various forms of initialization in Chapter 4, Section 4.2.
So, note the following. With
int upTo;
is the variable bis declared. You must not use it as it is now (for calculations and the like) because it does not yet contain a value. More precisely, its value is undefined ...
Read now
Unlock full access