File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static variables" Watch "Static variables" New topic

Static variables

Tim Moore

Joined: Jul 07, 2003
Posts: 17
Are variables declared in static methods static by default?
Jui Mahajan
Ranch Hand

Joined: Jun 02, 2003
Posts: 62
No, the variables in a static method cannot be static by default;they have to be declared explicitly static.By default, they r non-static

-----jui<br />scjp1.4
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Variables declared in a method are neither static (Class Variables) or non-static (Instance Variables) they are Automatic Variables (or Local Variables) and as such are not part of the state of an Object which is they only way static and non-static have any context.
JLS 8.3.1

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
I agree. Here's the link:
subject: Static variables
It's not a secret anymore!