• Post Reply Bookmark Topic Watch Topic
  • New Topic

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: 22846
43
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: 297
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!