开发者

Why are local variables also called "Automatic" in Java?

开发者 https://www.devze.com 2022-12-27 05:55 出处:网络
I read this in Kathy Sierra\'s book: \"Local variables are sometimes called stack, temporary, automatic, or method

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."

开发者_如何学Python

Why are the local variables called automatic?


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

 {
   int a = some_initialisation_value;
   ....
 }
 // a automatically vanishes here.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号