• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to define static variable inside method

 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
Why I am unable to define static variable inside a method, even under
static method. See the example below.

[ October 20, 2003: Message edited by: Sivanantham kandan ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's right. You can't define a static variable inside a method, only at class scope. That's how Java works.
Can you explain why you want to do this?
 
Derek Baker
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point of a static member (variable or method) is that it belongs to the whole class. It therefore does not make sense to define it inside a method.
 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you all.
Hi Derek,
It makes sense. Got it.
Hi Ernest,
I have no application in mind. That was just like that,
I was happen to try.
thanks
siva
x38020
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic