This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes method definition inside main... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "method definition inside main..." Watch "method definition inside main..." New topic
Author

method definition inside main...

Sumesh Kumar T N
Greenhorn

Joined: Jan 26, 2005
Posts: 10
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

Joined: Sep 28, 2004
Posts: 1228
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 .


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Abhinav Anand
Ranch Hand

Joined: May 02, 2002
Posts: 113
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.
 
GeeCON Prague 2014
 
subject: method definition inside main...