Default values and initialization in Java
In the first code sample, a is a main method local variable. Method local variables need to be initialized before using them. In the second code sample, a is class member variable, hence it will be initialized to the default value.