This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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).
 
Consider Paul's rocket mass heater.
 
subject: what 's wrong?