File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes difference between instance variable and simple variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between instance variable and simple variable" Watch "difference between instance variable and simple variable" New topic
Author

difference between instance variable and simple variable

Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
hi all,
i am little bit confused that difference between instance variable and simple variable.
if it is then please give me some examples.

thank you.


Strength Is Life,Weakness Is Death- Swamy Vivekanand.
SCJP 5.0(87%)
Ravikanth kolli
Ranch Hand

Joined: Feb 10, 2008
Posts: 179

I have never heard anything like a simple variable?
do you mean local variable?


-kolli
Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
sorry i should say simply a variable.i mean when we declare any variable as we declare in general case like:-
int a;
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18545
    
  40

Originally posted by tomendra singh:
sorry i should say simply a variable.i mean when we declare any variable as we declare in general case like:-
int a;


The difference between an instance variable and a "local" variable, is merely the scope. As long as the variable is in scope, there should be no difference in how they are used.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
thank you wong, but can you tell me please scope of both type of variables and how they are declared differently so that i can easily recognize that which one is instance variable and which one is instance variable.

(please explain with an example.)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11168
    
  16



There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
thank you very very much fred.
 
jQuery in Action, 2nd edition
 
subject: difference between instance variable and simple variable
 
Similar Threads
Difference between Static and Instance variable
variables in static methods
instance/reference
Instance and Reference variables
What's the difference between instance variable and class variable?