aspose file tools*
The moose likes Beginning Java and the fly likes What is the difference between instance variables and non local variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the difference between instance variables and non local variables" Watch "What is the difference between instance variables and non local variables" New topic
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: 39885
    
  28
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: 19762
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the difference between instance variables and non local variables