There are lot of
differences between instance variable, class variable and local variable in Java and knowing them will help you to write correct and bug free Java programs. Java is full featured programming language and provides different kind of variables like
static variable also called
Class variable since it belongs to whole Class,
non static also called
instance variable and
local variables which varies in scope and value. Thank god Java doesn't have any register variable or auto scope like C otherwise it would have so much detail to remember. static variables are common source of error in may multi-threaded
java program and does require a bit of carefulness while using it. On the other hand instance variable and local variable has less sharing visibility than static variable.