Two Laptop Bag*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what Watch "what New topic
Author

what 's wrong?

X Sun
Greenhorn

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
error.
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!
Bosun


Bosun (SCJP, SCWCD)
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
Sheriff

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

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what 's wrong?
 
Similar Threads
Which method gets called ?
anonymous inner class
intersting question
Object Reference Question
Why take code out of Main?