Uninitialized variables and members in Java

The language defines it this way.

Instance variables of object type default to being initialized to null.
Local variables of object type are not initialized by default and it’s a compile time error to access an undefined variable.

See section 4.12.5 for SE7 (same section still as of SE14)
http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.5

Leave a Comment