This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static Local Variable" Watch "Static Local Variable" New topic

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
That's the design of the java language.
The only modifier allowed for local variable is final.
Cindy Glass
"The Hood"

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
Don't get me started about those stupid light bulbs.
subject: Static Local Variable
Similar Threads
static declaration in main
why cant the output of the code is 2
static in a method
local variable!