This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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: 23867
50
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!