Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main in main - Compile time error

 
Jdinesh Tiwari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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
Posts: 88
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the compiler says you can't do it, you can't do it.
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Brown and Wilmot

Thanks for your kind reply.

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic