File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what 's wrong?

 
X Sun
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic