Two Laptop Bag
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 REST with Spring (video course) this week in the Spring 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
subject: Static Local Variable
It's not a secret anymore!