It's not a secret anymore!
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

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

Joined: Oct 13, 2005
Posts: 44476
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

Joined: Jul 22, 2000
Posts: 9056

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
wood burning stoves
subject: Static vriables and Methods
It's not a secret anymore!