| Author |
What is the difference between instance variables and non local variables
|
Vijay Tyagi
Ranch Hand
Joined: Feb 15, 2010
Posts: 52
|
|
the KB book says
Instance variables can be public,private,protected,default,final,transient
They can't be abstract,static,strictfp,synchronized,native
Non local variables can be public,private,protected,default,final,transient,static, volatile
What are non local variables ?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
Don't know. Maybe instance fields and static fields.
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
Vijay Tyagi wrote:
the KB book says
Instance variables can be public,private,protected,default,final,transient
They can't be abstract,static,strictfp,synchronized,native
Non local variables can be public,private,protected,default,final,transient,static, volatile
What are non local variables ?
It seems to me that non-local variables is the bigger pot that contains both instance variables and non-instance variables -- any variables that are not local to a block -- but of course I could be wrong.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
I agree with the both of you. Which brings up an important omission in the first statement: "Instance variables can be public,private,protected,default,final,transient". They can also be volatile. Static is the only difference between instance variables and non-local variables - because static makes them class variables and no longer instance variables.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: What is the difference between instance variables and non local variables
|
|
|