wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Static Local Variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static Local Variable" Watch "Static Local Variable" New topic
Author

Static Local Variable

Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
Why can't I get a static local variable???
Nain Hwu
Ranch Hand

Joined: Sep 16, 2001
Posts: 139
Matthew,
That's the design of the java language.
The only modifier allowed for local variable is final.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The word static means that it belongs to the whole class. It's lifetime starts when the class is loaded and dies when the class is unloaded - which for the most part means when the JVM goes down.
The word local means that it is only created when the method starts, and it dies when the method is over.

Can't be both at once, now, can it?


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
 
subject: Static Local Variable
 
Similar Threads
static
static declaration in main
why cant the output of the code is 2
static in a method
local variable!