June 2018
Beginner
722 pages
18h 47m
English
Let's look at the examples first. Let's assume we have these three lines of code consecutively:
int x; //declartion of variable xx = 1; //initialization of variable xx = 2; //assignment of variable x
As you can guess from the preceding example, variable initialization is assigning the first (initial) value to a variable. All subsequent assignments cannot be called an initialization.
A local variable cannot be used until initialized:
int x;int result = x * 2; //generates compilation error
The second line of the preceding code will generate a compilation error. If a variable is a member of a class (static or not) or a component of an array and not initialized explicitly, it is assigned a ...
Read now
Unlock full access