Why Java’s main() is `public static void`

As we know, in Java's Console Programme, its entrance method main() or main(String[] args)'s attribute is always public static void. It seems is a custom, but why? Is it neccessary?

Why public

  1. All we know public is an access specifier, which means we can call it outsite. A main method obviously should be called from outsite.

Why static

  1. static is a keyword to demonstrate this method can be used without creating its class/struct's instance. If loss it, JVM has to instantiate its class.
  2. If a main is not static, programme needs to create main's class's instance, so constructor may overload so that JDK cannot find a specific main().

Why void

  1. It's meaningless to get a main() method's return.


  1. Happyluke
    Posted 28 December 2020 at 9:55 AM | Permalink

    Excellent beat ! I would like to apprentice while you amend your web site, how can i subscribe for a blog site?

    The account aided me a appropriate deal.
    I were tiny bit familiar of this your broadcast offered shiny transparent idea

  2. Posted 10 January 2021 at 1:53 AM | Permalink

    352092 723836Superb weblog here! Also your web site loads up quickly! What host are you making use of? Can I get your affiliate link to your host? I wish my web site loaded up as swiftly as yours lol 693113

Post a Comment

Your email is never shared. Required fields are marked *