Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
vivek a naik
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jitendra.

I think O.S calls the main method implicitly.
is main a "Callback" method..?
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No not exactly. JVM will call the main method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic