What are the valid signatures for the main method? The only valid one I know of is: public static void main(String variable []) and "static" is required". Also, by default main is final. However, I tried the below with protected, private, and friendly, and I am not getting an error. Also, could you let me know if any of my assumptions are wrong or incomplete. <CODE> public class Parent { final void zzz() { System.out.println("zzz6"); } void main(String args []) { //errored must have static //static void main(String args []) { //no errors on below sign. //final static void main(String args []) { //final private static void main(String args []) { //private static void main(String args []) //protected static void main(String args []) //static void main(String args []) new Parent().zzz(); } } </CODE>
Do you know where I can get a hold of the Java VM specifications? This is for future reference, and I wanted to see the signature of the main method. That is the access modifiers, and if final is used by default.
Charlie Swanson
Ranch Hand
Joined: Jan 29, 2001
Posts: 213
posted
0
Ravinda, Thank you for your answer. I am glad I was not loosing it.
shailesh sonavadekar
Ranch Hand
Joined: Oct 12, 2000
Posts: 1874
posted
0
Charlie , If I have not mistaken , JAVA VM specifications are available for free download from www.javasoft.com ( Books in Sun series ). I hope that can be helpful to you. Your Friendly Bartender Shailesh.
Jane Griscti
Ranch Hand
Joined: Aug 30, 2000
Posts: 3141
posted
0
Hi Charlie, Just an FYI, <code>main()</code> is not <code>final</code> by default. The following is also a valid declaration:
The only caveats are:
'void' must precede 'main'
it must be declared 'public'
it can have only one parameter which must of type 'String[]'
<code>main()</code> is treated as any other method with the exception that it has the 'special' meaning of being the first method the JVM will look for when an application is started. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform
[This message has been edited by Jane Griscti (edited May 24, 2001).]