File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "main() method????" Watch "main() method????" New topic

main() method????

Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
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: 3635
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.
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

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

Joined: Nov 01, 2000
Posts: 5

main method need not have this exact signature : public static void main

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.
I agree. Here's the link:
subject: main() method????
jQuery in Action, 3rd edition