Inner Classes
by , 04-26-2012 at 05:01 PM (438 Views)
Inner class has a link with enclosing class instance just the way with instance methods & variables. It also has a direct access to fields and methods of the object. Because of the association of the inner class with an instance, static member cant be defined by it.
Inner classes instances i.e. object are present in outer class instance. Let us consider these classes:
Innerclass’s instance just can exist in the Outerclass instance & also possess the direct access to enclosing instance’s fields and methods. This has been illustrated as following:Java Code:class OuterClass { ... class InnerClass { ... } }
Inner Classes
For instantiation of the inner class, outer class shall be instantiated first of all. After this, inner object shall be created in out object, with this syntax:
In addition to this, 2 kinds of the inner classes are: anonymous classes and local classes.Java Code:OuterClass.InnerClass innerObject = outerObject.new InnerClass();










Email Blog Entry
License4J 4.0
Yesterday, 12:23 AM in Java Software