File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes methods in methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "methods in methods" Watch "methods in methods" New topic

methods in methods

Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

may i know why this does not this program get compiled?

public class HelloName{
public static void main(String args[]){

void abc(){ }

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Because you're trying to define a method inside another method, something the Java language does not allow? Some folks recently had a discussion about this very thing here; check it out if you're interested.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: methods in methods
It's not a secret anymore!