views:

110

answers:

2

I read this in Kathy Sierra's book:

"Local variables are sometimes called stack, temporary, automatic, or method variables, but the rules for these variables are the same regardless of what you call them."

Why are the local variables called automatic?

+3  A: 

Local variables automatically cease to exist when the execution of the block in which they are declared completes.

 {
   int a;
   ....
 }
 // a automatically vanishes here.
codaddict
you can not declare just int a; a should be initialized.
giri
A: 

Good ol' Wikipedia

In computer programming, an automatic variable is a lexically-scoped variable which is allocated and de-allocated automatically when program flow enters and leaves the variable's scope. The term local variable is usually synonymous with automatic variable, since these are the same thing in many programming languages.

mobrule