The initiated objects of the class can live past the life of method invocation, once the method returns and the stack unwinds the local variables are gone, but the object is still alive. Local classes can however use final local variables.
Joined: May 05, 2009
is it possible to use the method-local inner class as return type of the method where the inner class is in?
Joined: Mar 07, 2009
bob jacosin wrote:is it possible to use the method-local inner class as return type of the method where the inner class is in?
No but you can return the super type, or pass it as a parameter to a method that accepts its supper type or assign it to a instance variable ( of a type that is super class of your local class). If there is any outside reference to the local class object after the method finishes it will still be accessible.