Java- Variables and default values

Class-level variables are implicitly initialized with default value.

Data Type Default Value (for fields)
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char '\u0000'
String(or any object) null
boolean false

Local variables should be initialized before accessing as they are not implicitly
assigned with default value.

Post a Comment

0 Comments