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
  • 8
    "You cannot call static methods through an instance" Actually, one of Java's quirks is that you CAN call static methods through an instance, even though it's an exceedingly bad idea. Commented Feb 8, 2010 at 18:17
  • 1
    Indeed Java does allow static members to be accessed via instances: see Static variable in Java Commented Sep 20, 2012 at 5:24
  • A proper modern IDE will generate a warning when you do that though, so at least you can catch it while Oracle can keep the backwards compatibility thing going. Commented Jan 4, 2013 at 9:24
  • 1
    There is nothing conceptually wrong with being able to call a static method through an instance. This is quibbling for quibbling's sake. Why should something like a Date instance NOT call its own static methods passing instance data to the function through the calling interface? Commented May 11, 2014 at 18:30
  • @RichieHH That is not what they are quibbling about. The question is why is it allowed to call variable.staticMethod(), instead of Class.staticMethod(), where variable is a variable with declared type Class. I agree it is bad language design. Commented Nov 24, 2018 at 15:26