Click here to Skip to main content
15,943,729 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have just begun to learn java. I read in a book that the Java compiler compiles classes that do not contain a main() method . But java has no way to run these classes . So ,if we type Main instead of main, the compiler would still compile the program . However, java would report an error because it would be unable to find main() method .

What is the difference between the two ?

What I have tried:

I found this in the book Java The Complete Reference by Herbert Schildt
Updated 14-Jan-17 4:46am
Afzaal Ahmad Zeeshan 14-Jan-17 8:31am    
Your question made sense, but the title is so irrelevant.

Java, like most other languages, is case sensitive when it comes to classes, methods, objects etc. So a method called Main is not the same as one called main. You can compile any number of classes independently, and they do not all need to include a static main method. However, you must have such a method somewhere amongst all the classes in order to run the application. The main method is where the program always starts from. You can find lots of good information in The Java™ Tutorials[^].
Share this answer
Afzaal Ahmad Zeeshan 14-Jan-17 8:32am    
Richard MacCutchan 14-Jan-17 8:57am    
So ,if we type Main instead of main

Java is case sensitive, it means that main and Main are 2 different things.
Main is user (you) defined name, just like any other name you define for your app.
main is language defined, this is the piece of code that is launched when your app is loaded. Note that you can't call main from your code.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900