Default values in Java

From Juneday education
Jump to: navigation, search

Note that local variables never, ever, get default values in Java. Instance variables and static (class) variables get default values. Elements of a new array also get default values (when the array is created).

Default values are false for boolean variables, and zero for numeric types and null for reference types (reference types are Interface, Class, Enum and array type variables).

Here's more information: Primitive Data Types

It is a common mistake to claim that "Java variables get default values" because local variables don't.