This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

main in main - Compile time error  RSS feed

 
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?

.
 
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.
 
Bartender
Posts: 4568
9
  • 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
Boost this thread!