• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the difference between instance variables and non local variables

 
Vijay Tyagi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Maybe instance fields and static fields.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic