FAQ

Java

JSP

Servlet


Advertisement



What are instance variables in Java?

Instance variables are any variables, without "static" field modifier, that are defined within the class body and outside any class's methods body. 

Instance variables are in scope as long as their enclosing object is in scope. An instance variable is a part of the object that contains it and cannot live independently of it.

All object instances have their own copies of instance variables. One object instance can change values of its instance variables without affecting all other instances.

Instance variables can be used by all methods of a class unless the methods are marked with "static" modifier. You access instance variables directly from their containing object instances.


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |