aspose file tools*
The moose likes Java in General and the fly likes Instance Variable vs. Class Variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Instance Variable vs. Class Variable" Watch "Instance Variable vs. Class Variable" New topic
Author

Instance Variable vs. Class Variable

Patrick Day
Greenhorn

Joined: Jul 23, 2011
Posts: 8

I have been studying and came across this terminology, that thoroughly confused me. What exactly is the difference between an instance variable & class variables, are they not the same thing?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4246
    
    7

The way I'd expect the terminology to be used: for an instance variable, there's one variable belonging to each instance of the class. For a class variable, there's a single variable belonging to the class. In Java that corresponds to the variable being declared static.
Patrick Day
Greenhorn

Joined: Jul 23, 2011
Posts: 8

So...a class variable is just another term for a static variable or field?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Yes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Patrick Day
Greenhorn

Joined: Jul 23, 2011
Posts: 8

Thanks for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instance Variable vs. Class Variable
 
Similar Threads
Anonymous classes
doubt in has-a relationship
What's the difference between instance variable and class variable?
Static final fields and final fields
java (beginner)