File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes main() method???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "main() method????" Watch "main() method????" New topic
Author

main() method????

Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
Hi,
I,m new to javaRanch and preparing for the exam. I,ve a problem .
Correctly defined main() method is said to be
public static void main(String[] u){}
I tried with
private static void main(String[] u){}
final static void main(String[] u){}
protected static void main(String[] u){}
static void main(String[] u){}
All of them compiled and run without any change.
Could anyone help me on this??
Nasir Khan.
Sasikanth Malladi
Ranch Hand

Joined: Nov 04, 2000
Posts: 175
All the compiler checks to see is whether or not a main method is present. That's good enough. It will compile but when you try to run it, the JVM will check to see if there exists a main method looking like: public static void main(String somevar[]) and if it's not found, you get an error.
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3324
    
    8
Actually, it compiles as well as runs with other modifiers diff. JDKs. But according to the specs and for the purpose of the exam, it should be public.
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
madhumathi k
Greenhorn

Joined: Nov 01, 2000
Posts: 5

main method need not have this exact signature : public static void main
Refer http://developer.java.sun.com/developer/bugParade/bugs/4252539.html
http://www.ibiblio.org/javafaq/reports/privatemain.html

but for the sake of the certification exam just forget what is mentioned in the above sites and remember the signature of the main method given above.
HTH !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main() method????