aspose file tools*
The moose likes Beginning Java and the fly likes main in main - Compile time error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "main in main - Compile time error" Watch "main in main - Compile time error" New topic
Author

main in main - Compile time error

Jdinesh Tiwari
Ranch Hand

Joined: Jan 13, 2013
Posts: 35
[Added code tags - see UseCodeTags for details]

2 compile time Errors are as --> Illegal start of Expression at second main and Class Interface or Enum Expected
If i am giving main within a main than what`s the problem at least it should compile .
Why it is not possible to define main within a main?

.
Mack Wilmot
Ranch Hand

Joined: Jul 27, 2011
Posts: 88

If the compiler says you can't do it, you can't do it.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

It's much more general than that. You can't define any method within a method. They need to be directly in the class body.

(And why on earth would you want to do this?)
Jdinesh Tiwari
Ranch Hand

Joined: Jan 13, 2013
Posts: 35
Dear Brown and Wilmot

Thanks for your kind reply.

That means in any case we can`t define a method within a method.

 
 
subject: main in main - Compile time error