Why didn't Java support nested methods

Does Java support inner / local / child methods?

Update 2014-02-09:

With JDK 8 lambdas (anonymous function expressions) have been introduced that you can use to solve the problem in the following ways:

(JDK 7 and lower)

No, Java does not support "directly" nested methods. (Most functional languages, including some JVM languages ‚Äč‚Äčlike Scala and Clojure!)

For reference only; you can Define local classes (classes within methods) so that these compile

Note, however, that there are some restrictions on local classes

3.11.2. Limitations on local classes

Local classes are subject to the following restrictions:

  • A local class is only visible within the block that defines it. It can never be used outside of this block.

  • Local classes cannot be declared public, protected, private, or static. These modifiers are intended for class members. They are not permitted for local variable declarations or local class declarations.

  • For the same reasons as member classes, local classes cannot contain static fields, methods, or classes. The only exception is constants that are declared both static and final.

  • Interfaces cannot be defined locally.

  • Like a member class, a local class cannot have the same name as any of its enclosing classes.

  • As mentioned earlier, a local class can use the local variables, method parameters, and even exception parameters that are in its scope, but only if those variables or parameters are declared final. This is because the lifetime of an instance of a local class can be much longer than the execution of the method in which the class is defined. Because of this, a local class must have a private internal copy of all local variables it uses (these copies are automatically generated by the compiler). The only way to ensure that the local variable and the private copy are always the same is to insist that the local variable is final.

As you can see, your first option (with no nested methods) is preferable in these situations.