Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 04:22 AM
Member
 
Join Date: Jul 2007
Posts: 40
lenny is on a distinguished road
The main method in java...
Hi, I know that in C and Java the program control starts from the main method..
But can anybody explain
  1. Why is that the main method is the starting of program
  2. Why is that the main method is given preference over any other methods??
  3. Why is it named as main method?
  4. How does the compiler knows that main method is the starting?
  5. What is the compiler process(program) to identify uniquely the main method
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 07:21 AM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
I think its a keyword the language designer put in the language code or compiler or the linker, the compiler and linker itself are a program after all right?

The main method is given preference over others cuz this method is supposedly the main control, the core control of the program, if there's no core control, things might go unorganized and lead to hectic right?

Upon why it is named the main method or why they use it, well, thats really up to the designer preference in the first place actually, they put the name [b]main[/] to state that this is the core of the program, the main flow where everything works

If i were the designer i might just use core as the keyword, or something else, instead of main
Just a record, Java is a derivation of C++, so its not really that strange if they use main as well as the core control

Bout how it identify the main method, i don't really know, since i don't study the inner programs of C and Java compilers and linkers, but i have seen some webs in the net that dwell on this subject, try googling for it
But from my point of view, I think it would just be the same as identifying any other method, just that this one method is named as main() in C++ or main(String[] args) in Java to tell the compiler, that it should do the flow following this method
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A query about main method mew New To Java 2 12-24-2007 10:44 AM
Calling main method eva New To Java 1 12-22-2007 01:14 PM
Private main method bugger New To Java 1 12-21-2007 10:45 AM
main method eva New To Java 5 12-19-2007 10:25 AM
exception in thred main java.lang.nosuchmethoderror: main fernando Java Applets 1 08-06-2007 10:11 AM


All times are GMT +3. The time now is 09:38 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org