1.6 Initializations
Introduction
Initialization is giving a variable its first value, often combined with declaration in a single statement. Java treats declaration and initialization as separable steps for local variables, but requires initialization before first use — either explicitly by the programmer, or implicitly by the JVM for instance/class fields (which default to 0, false, or null).
Key Concepts
Java Syntax
Code Examples
`fieldCount` is a static field, so the JVM zero-initializes it automatically. `localCount` is a local variable inside `main`, so it must be assigned explicitly before use.