File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nesting a method within a method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Nesting a method within a method" Watch "Nesting a method within a method" New topic
Author

Nesting a method within a method

Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
Is there any way to nest a method within another method?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41123
    
  45
No. What are you trying to accomplish by doing that?


Ping & DNS - my free Android networking tools app
Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
Order

I was just wondering. There are many possibilities in Java and I was thinking about this one.

Thanks for your answer.
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
You can declare a local class within a method, and that class can have its own methods. That's probably the closest thing to a "method within a method" in Java.


SCJP 5.0
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Nesting a method within a method
 
Similar Threads
why not we define a static member function inside a main
I have got two conclusion from above code is that
A question about thread safety and servlets
A question about thread safety and servlets
NPE with JTextArea