Can anyone explain what is meant by unpredictable data and unpredictable behavior here.
If you programmed in C / C ++, you would have noticed that an uninitialized variable carries some garbage value that is present in the allocated memory cell, it is interpreted as the data type of the variable. The compiler does not complain about such variables, and if the developer forgets to initialize them correctly, garbage values will be used, which will lead to unexpected behavior of the program.
In Java, the JVM initializes all member variables to standard values based on the data type of the variable and complains about local variables that are not initialized at compile time to avoid this unexpected behavior and force the developer to always use initialized variables.
Vikdor
source share