Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 30
    Expanding on "There's no instance to take a value from" - even if there are instances, the static method can't know which instance to take a value from. Commented Sep 11, 2013 at 18:53
  • 10
    This is a lot less complicated to explain in languages that don't force everything to be part of an object by default. Commented Sep 13, 2013 at 0:00
  • 3
    @Mason True words. Languages like Java kind of enforce a false notion that a function is something that necessarily belongs to a class. Commented Sep 13, 2013 at 12:29
  • 5
    This is a fine answer but it still fails to tell the whole truth: static methods can access non-static data. They just don't have the implicit object or this-reference available. I think that is vitally important to understand. Commented Sep 13, 2013 at 13:38
  • 2
    @COMEFROM You mean by explicit passing? I can make a note of it, if I'm understanding you correctly. I assumed it was implied that a static method could access explicitly passed non-static data, given that any function can work on data explicitly passed to it. Commented Sep 13, 2013 at 15:16