static members belong to the class, not to the instance(s),
the class with its (static) members lives in perm space (special kind of heap),
instances live on the regular heap
method local variables belong to the executing thread,
thread local variables are allocated on the stack,
thread local variables go out of scope when the method completes
> Hi,
>
> Why a local variable can not be declared as static?
> What is the logic behind this static keyword?
>
> thks.
In C, a static local variable is used to maintain state between function calls. In Java, the way to maintain state is with a member variable. We have no need of static local variables.
The meaning of the static keyword is "associated with the class as a whole, rather than with any one instance."