aspose file tools*
The moose likes Beginning Java and the fly likes method inside main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "method inside main method" Watch "method inside main method" New topic
Author

method inside main method

Asanga Aux
Greenhorn

Joined: Oct 19, 2009
Posts: 1
Hey,

Why cant we declare a method inside the main method and call it?



why its giving illegal start of expression ?

Thank You.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

inside a main method ,you can declare a method(static) . but you cant define(implement) a method.

Hope this helps
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

and welcome to javaranch
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

Welcome to JavaRanch.

Because it is simply not possible in Java to define methods inside methods. It's just not part of the language's syntax.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method inside main method