Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Static vriables and Methods

 
Ranch Hand
Posts: 198
  • 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.

 
Marshal
Posts: 65110
247
  • 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.
 
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!