Local Classes:-> Static Local Classes � These are classes - TopicsExpress



          

Local Classes:-> Static Local Classes � These are classes declared inside static methods. � They can declare non-static members and static constants. � No accessibility modifiers can be used with these classes. � To create an object of Static Local Class, you dont need an instance of its enclosing class. � An instance of enclosing class is not stored in an instance of a Static Local Class. � They can access static members of the enclosing class including private static members. � They can access non-static members of the enclosing class(including private non-static members) on an object of the enclosing class. � They can access non-hidden final local variables i.e. variables of the enclosing method including final parameters passed to the enclosing method. � They must be declared before use. � An object of a Static Local Class can only be created inside the enclosing method as it is local to that method. � All the constants declared in a method which are used in the local class must be assigned a value before the declaration of the local class. If you have not read how Static Member Classes and Non-Static Member Classes work, then I recommend that you read Static Member Classes and Non-Static Member Classes first before continuing. Non-Static Local Classes � These are classes declared inside non-static methods. � They can declare non-static members and static constants. � No accessibility modifiers can be used with these classes. � To create an object of Non-Static Local Class, you need an instance of its enclosing class. � An instance of enclosing class is stored in an instance of a Non-Static Local Class. � They can access all members of the enclosing class including private members. � They can access non-static members of the enclosing class(including private non-static members) on an object of the enclosing class. � They can access non-hidden final local variables i.e. variables of the enclosing method including final parameters passed to the enclosing method. � They must be declared before use. � An object of a Non-Static Local Class can only be created inside the enclosing method as it is local to that method.
Posted on: Fri, 19 Sep 2014 04:14:45 +0000

Trending Topics



Recently Viewed Topics




© 2015