This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

difference between reference variable and instance variable  RSS feed

 
Greenhorn
Posts: 19
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello guys,

I have just started prep for scjp,
but i'm confused about reference variable and instance variable,
b'cos I can't not see diff between them,

PLEASE help me with an example

Thanks,
 
Sheriff
Posts: 23640
48
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Now go back and read your instructional material about those two concepts. Compare what that says to the example there.
 
Ranch Hand
Posts: 300
Eclipse IDE Firefox Browser Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi krunal ,

In Java three kind of variables are possible

1. Class variable (declared by using keyword static)
2. Instance variable ( declared in Class but without static)
3. local variable (declared in block, method argument or inside methods)

reference word is used for pointing towards object in heap , so if any variable is not primitive type and its pointing to object you can call it as reference variable just for namesake but above three are variables based on scope.

hope this would be useful.
 
krunal prajapati
Greenhorn
Posts: 19
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You so much Javin and Clapham.
With the help of you I understood it very practically.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!