• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static vriables and Methods

 
Varuna Seneviratna
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9062
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic