Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main() doubts

 
Mahesh Barik
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me to which to class main() belongs,as we know for each method there is a particular class.so main() as a method it should be under a class that would be predefined.

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It belongs to the class you want to execute. It can be any class.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is predefinied by the JVM.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mahesh Barik:
...so main() as a method it should be under a class that would be predefined...

A "main" method is not predefined for any particular class. It can be included in any class you decide to put it in. What is predefined is the way main (with the proper signature) is used as an entry point...

"A Java virtual machine starts execution by invoking the method main of some specified class..." (JLS - 12.1 Virtual Machine Start Up).
[ October 10, 2006: Message edited by: marc weber ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic