Thursday, May 08, 2008

Default Values of Primitives in Java

Default values apply only to instance variables that are uninitialized. Local variables need to be initialized explicitly before use or else the compiler will yell at you.


boolean - false
byte - 0
short - 0
char - ‘\u0000′
int - 0
long - 0L
float - 0.0F
double - 0.0D

No comments: