wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Instance variable and Reference variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instance variable and Reference variable " Watch "Instance variable and Reference variable " New topic
Author

Instance variable and Reference variable

nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 364
Is instance variable and reference variable same or diferent ? Is it different names for same thing or different things altogrther ? Is there any other name they are known as (may be "object variable") ?

If they are different, then whats the difference between them ?

Thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

nirjari patel wrote:Is instance variable and reference variable same or diferent ? Is it different names for same thing or different things altogrther ? Is there any other name they are known as (may be "object variable") ?

Those are two different concepts. An instance variable is a non-static member variable of a class. All variables of non-primitive types are reference variables in Java. A variable can be an instance variable and a reference variable at the same time, ofcourse.

Besides instance variables, you have class variables (static member variables of a class) and local variables (locally declared in a method or other block of code).

Besides reference variables, you have variables of primitive types (byte, short, int, long, float, double, boolean, char).

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instance variable and Reference variable
 
Similar Threads
regard on k&b book
Pass-by-Vaule Object reference question
Overiding class variable through inheritance
Exception declaration
Overridding Pls Explain this code