Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static variables

 
Tim Moore
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are variables declared in static methods static by default?
TM
 
Jui Mahajan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic