Saturday, November 20, 2010

Java - Instance Variables

Prior to this point, all the the variables we used we declared in an application's main method.

When a variable is declared in the body of a method, it is categorized as a "local variable', and that variable can only be used inside that method.

When the particular method terminates (right after it finishes execution), all values of its local variables terminate with it.

**On the other hand, objects can have attributes that it carries with it, regardless of whether one of its methods are in execution or have finished execution or not.

**These attributes exist before a method is called (as soon as an instance of the object is instantiated), and continues to exist independent of the execution or completion of any of its methods.

No comments:

Post a Comment