
Local variables are the medium to small scope variables. Usually, you will use these much more frequently than instance variables.
However, since the variable's scope is only the method it's declared in, they can't be used in a different method if they are not declared.
Compiler error using variables out of scope |
Why should you care?
As with instance variables, local variable scope can often be figured out by trial and error. However, understanding how local variables work can save you a lot of time as a programmer.
No comments:
Post a Comment