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 what 's wrong? 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 "what Watch "what New topic

what 's wrong?

X Sun

Joined: Nov 26, 2000
Posts: 4
I think the main() doesn't have args. It is a problem.
But I get the runtime error. I think it should be compiling
Btw, main is the keyword?
what is the definition of keyword.
public class TestClass
public static void main(){ new TestClass().sayHello(); } //1
public static void sayHello(){ System.out.println("Static Hello World"); } //2
public void sayHello() { System.out.println("Hello World "); } //3
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
No, it will be a runtime error. When the compiler comes accross your main definition, it just considers it another method. Now when you try to execute your program, the JVM cannot find a properly defined main method, then it barks!

So much trouble in the world -- Bob Marley
Mahajan Bhupendra
Ranch Hand

Joined: Dec 01, 2000
Posts: 118
main is not a keyword
u can have a
varirable like
int main;
it works i have tried..
it's entry point of every java application..

<B>Bhupendra Mahajan</B>
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
'X Sun'
Please Read the JavaRanch naming policy for more details.
Javaranch appreciates your cooperation to comply with the official naming policy.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
I agree. Here's the link:
subject: what 's wrong?
jQuery in Action, 3rd edition