Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: 137
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
It's not a secret anymore!