| Author |
Instance variable and Reference variable
|
nirjari patel
Ranch Hand
Joined: Apr 23, 2009
Posts: 265
|
|
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
Bartender
Joined: Aug 16, 2005
Posts: 12953
|
|
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
|
 |
 |
|
|
subject: Instance variable and Reference variable
|
|
|