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 Static vriables and Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static vriables and Methods" Watch "Static vriables and Methods" New topic
Author

Static vriables and Methods

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
I wrote the below program with the intention of doing some exercises about static variables and methods.I want to find out ,when a variable is declared within a static method without defining the variable as static , that the declared variable is static or not.How am I to find it out from a program like this.



Varuna Seneviratna
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
It is neither static nor instance type if declared inside a method. It is a local variable, and only has scope inside its enclosing block/method.

BTW: There are compiler errors in the code you posted. Always use ctrl-C-ctrl-V to Post Real Code. Then we can be confident that we can compile what you posted.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Static vriables and Methods