wood burning stoves 2.0*
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static variables" Watch "Static variables" New topic
Author

Static variables

Tim Moore
Greenhorn

Joined: Jul 07, 2003
Posts: 17
Are variables declared in static methods static by default?
TM
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
Sheriff

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 http://java.sun.com/docs/books/jls/first_edition/html/8.doc.html#37544


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
wood burning stoves
 
subject: Static variables