This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Instance variable and Reference variable

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic