View Feed
group-icon
Java Developers
Community of Java Developers: Get Java Programming Help from fellow Java Developers across the world.
654 Members
Join this group to post and comment.
Aadesh
Aadesh • Sep 24, 2012

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

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??
Anoop Kumar
Anoop Kumar • 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 • Sep 25, 2012
is it possible to create more than 1 main() in a java program?
Anoop Kumar
Anoop Kumar • Sep 25, 2012
why not try yourself 😀

Share this content on your social channels -