File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Why Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why " main() "  is a Watch "Why " main() "  is a New topic

Why " main() " is a 'public static' method..??

vivek a naik

Joined: May 15, 2008
Posts: 9
Why is it necessary to add "Public static " modifiers in main() method.

is it just because we dont have to create an object to call it..??
Jitendra Jha
Ranch Hand

Joined: Jan 28, 2007
Posts: 91
static methods are class methods and do not need an object to run..
we also know that methods(non-static) are called from an object.
when we execute a java program,main is loaded first
since no object(of the particular class) is present at that time hence not having "static" would not help us in running the program...
[ May 26, 2008: Message edited by: Jitendra Jha ]

vivek a naik

Joined: May 15, 2008
Posts: 9
Thanks Jitendra.

I think O.S calls the main method implicitly.
is main a "Callback" method..?
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
No not exactly. JVM will call the main method.
I agree. Here's the link:
subject: Why " main() " is a 'public static' method..??
It's not a secret anymore!