Question subject: Local variables vs Instance variables
Posted: Thu Jan 29, 2009 4:05 pm
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
Local variables vs Instance variables Here i compare between two terms in Java Local variables and instance variables .
Local variables : Are the variables declared inside the function. Their scope is limited to the function .They can be only accessed inside the function. They are deleted at the end of method.Local variables are called stack variables because they are saved in the stack.
Instance variables: All the variables created in the class and not inside a function .Their scope is the scope of the class instance and they are saved in the heap .
you may need to know that there is a variables named " static variables , these variables is declared using the static modifier ,and their scope is the scope of the class it self. static variables can be accessed from static or non-static variables .
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )