As I knew the scope of the Local Class is in the block/Method in which it is declared.
just tried this example
the statement Local.Innerlocal il=l.new Innerlocal(); throwing error.
is there any way to access local class in main?
As you just mentioned, a local class can't be directly "accessed" outside of the block/method that it is declared. So hence, it is out of scope when you tried to instantiate it, in the main method.
You can, however, call the loc() method from the main method -- where a local inner class object can be created and returned. There is one caveat. Since the definition of the inner class is out of scope, you can't return it as the inner class type.
Now, if this inner class, inherits from a class that is in scope, or implements an interface that is in scope, it can be referred to by that type. Unfortunately, in your case, it can only be returned to the main method as an java.lang.Object object.
Henry