GeeCON Prague 2014*
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


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: 374
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: 14194
    
  20

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 8 API documentation
 
GeeCON Prague 2014
 
subject: Instance variable and Reference variable