| 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
|
|
|
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
|
 |
 |
|
|
subject: Instance Variable vs. Class Variable
|
|
|