aspose file tools*
The moose likes Beginning Java and the fly likes Diff between instance variable and class variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Diff between instance variable and class variable" Watch "Diff between instance variable and class variable" New topic
Author

Diff between instance variable and class variable

VishnuKumar Prasad
Greenhorn

Joined: Nov 09, 2000
Posts: 11
hi
plz give the difference between c++ and Java
and also difference between Instance variable and class variable
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
This is a link to an article listing the comparison of Java to C++ http://java.sun.com/docs/white/langenv/Simple.doc1.html
An instance variable is a variable that exists in each occurance or instance (object) of the class that is created. This is how you keep track of the attributes of each instance separately from the other instances.
When you say class variable I believe that you are referencing static variables. When the class is first loaded (before any instances are created) the static variable(s) is created. A static variable only exists once for all instances of the class. An example is the static variable pi in the math class. There is only 1 pi, and all the instances use it.
In addition there are local variables. These exist only inside methods and when the method invocation is over they cease to exist.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Diff between instance variable and class variable
 
Similar Threads
What's the difference between instance variable and class variable?
variables in static methods
instance/reference
definitions
Difference between Static and Instance variable