File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instance/reference

 
b reddy
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between an instance variable and an reference variable?
 
Meena R. Krishnan
Ranch Hand
Posts: 178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Instance variable is a variable that is defined inside a class outside any method and without the 'static' modifier. These variables belong to each instance of the class' objects. These variables get initialized when an instance of the class is created.

A reference variable is used to access an instance of an object.


[ April 30, 2007: Message edited by: M Krishnan ]
 
vish vodeyar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An object that belongs to a class is said to be an instance of that class. The variables that the object contains are called instance variables.

There is a special portion of memory called the heap where objects live. Instead of holding an object itself, a variable holds the information necessary to find the object in memory. This information is called a reference or pointer to the object. In effect, a reference to an object is the address of the memory location where the object is stored. When you use a variable of class type, the computer uses the reference in the variable to find the actual object.This variable is called the reference variable.

I think i have explained this concept to the best of my knowledge.
thanks and regards
-vodeyar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic