Without checking, I'd say that this isn't accepted by the compiler because as of this time methods need to be defined within a class. However, you could define an inner class inside the method (see "Local and Anonymous Inner Classes").
http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html