Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the difference between instance variable and class variable?

 
theMatrix
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference between instance variable and class variable?
 
datakix
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference between an instance variable and a class variable is that an instance variable does not belong to the class, it belongs to an object (an INSTANCE of a class); whereas the class variable belongs to the class and not to any INSTANCE of the class.
- datakix
 
william shen
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
generally,we can say variables with the static modifier are class variables and the rest are instance variables.
Originally posted by theMatrix:
What's the difference between instance variable and class variable?

 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
datakix
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
Thanks for your cooperation.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic