Re: variables?



Michael wrote:
Hello all, I need some reinforcement with variables.
Are instance variables the same as fields( which are found outside a method, but within a class). And local variables are found within methods. Is that correct terminology?; the reason I ask is because a couple different books, and sites refer to these variables by different names. My understanding is instance variables become the state of a object, whereas local variables work with the methods. Can anyone verify this. Thanks again






That is correct, but not all variables outside a method and within a class are "instance variables". If you declare such a variable as static, then it becomes a "class variable".


other than that, what you described is correct.
.



Relevant Pages

  • Re: Object reference
    ... public void manage{ ... On your list of things to study and try, put instance variables (also known ... // Declare local variables here. ... // Do some things with local variables. ...
    (comp.lang.java.programmer)
  • Re: ruby1.9 block scope
    ... dynamically generated _unique_ classes bound to the current context ... different scopes containing instance variables to that current context. ... for local variables that have been assigned to before the code blocks. ...
    (comp.lang.ruby)
  • Re: cannot get attr_accessor to work
    ... On Wed, 21 Jan 2009, Tom Cloyd wrote: ... nut. ... Ruby is interpreting log and logging_now as local variables. ... post make it clear that I'm dealing with instance variables? ...
    (comp.lang.ruby)
  • variables?
    ... I need some reinforcement with variables. ... Are instance variables the same as fields(which are found outside a method, ... And local variables are found within methods. ... Prev by Date: ...
    (comp.lang.java.help)
  • Re: basic mistake?
    ... declare your instance attributes inside initialize. ... Local variables are visible in their local scope. ... Instance variables are scoped to, or associated with, "self". ...
    (comp.lang.ruby)