Why makers of Java didn't give the main() function Public and Static as an inbuilt functionality?

Aadesh

Aadesh

@aadesh-FqoMCL Oct 27, 2024
Interface Methods have inbuilt functionality of being abstract and public (ie we do not neccessarily have to declare them Abstract / Public)
Similiarily Interface Variables are Public, Static and Final!!

Obviously there are certain reasons for this!!

My doubt is why dint the makers of Java give the main() function Public and Static as an inbuilt functionality? I mean main() is the Starting point of program execution and it must be accessible from everywhere , thats why we use static public, i know!!
but Since Everytime we use main(), if it has to be static and public, then why dint they makers of java give it an in-built functionality??

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Sep 24, 2012

    main method is a class member and when program start running JVM looks for standard definition public static void main(String []args) .
    if main() would only used for starting point.. then what happen if developer wants to create his/her own method name main().


    Basic idea of interface is contract between client and developer that following name of methods will be there and developer will implement by its own
    while variable are client chosen which obviously should not be changed that is why static,final.
  • Aadesh

    Aadesh

    @aadesh-FqoMCL Sep 25, 2012

    is it possible to create more than 1 main() in a java program?
  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Sep 25, 2012

    why not try yourself 😀