Results 1 to 2 of 2
  1. #1
    lenny is offline Member
    Join Date
    Jul 2007
    Rep Power

    Default 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


  2. #2
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Rep Power


    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

Similar Threads

  1. Calling main method
    By eva in forum New To Java
    Replies: 7
    Last Post: 11-06-2009, 01:37 PM
  2. A query about main method
    By mew in forum New To Java
    Replies: 2
    Last Post: 12-24-2007, 09:44 AM
  3. Private main method
    By bugger in forum New To Java
    Replies: 1
    Last Post: 12-21-2007, 09:45 AM
  4. main method
    By eva in forum New To Java
    Replies: 5
    Last Post: 12-19-2007, 09:25 AM
  5. Replies: 1
    Last Post: 08-06-2007, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts