I have a basic understanding of c++ and that about as far as my programming knowledge extends. I was lead to belive void main was a bad thing yet in every sample program i've seen in java this seems standard practice, why?
Marilyn de Queiroz
Joined: Jul 22, 2000
main() a bad thing?
You need to have a method named public static void main( String args ) to start off any java application. You may not need main() in every class in your project, but you certainly need one or your app won't run.
If you only program applets or servlets you could, however, get by without a main() method.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Jul 11, 2001
The main method in Java *has* to have a return value of "void" per specification. In C/C++, it is a good practice to let main have a return value of int to specify the exit code of the program. In Java, a program has an exit value of 0 by default - if you want to specify a different value, you need to use System.exit(exitCode).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus