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
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply 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: 3796
    
    1

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: 19216

Yes.


SCJP 1.4 - SCJP 6 - SCWCD 5
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Instance Variable vs. Class Variable
 
Similar Threads
doubt in has-a relationship
java (beginner)
What's the difference between instance variable and class variable?
Anonymous classes
Static final fields and final fields