Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method definition inside main...

 
Sumesh Kumar T N
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible to define another method inside main???.....a friend of mine said that we could define "procedures"(???) inside main....im a bit confused...i am sorry if it is stupid...but lemme have a reply pleez
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be a class inside other class called nested class but you cant have a method inside another method.

A suggestion, the best way to figure out issues like this is to write a simple code and compile it then you can learn lot .
 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think your friend was talking about anonymous classes which can be declared and executed inside a method (no matter if it is done in main() method). Code snippet is given below:



Hope this clears the doubt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic