Definition of Local inner class:
When we define a class, local to the function, just as a local variable, then it is known as a local inner class. Local variables of a function are not accessible from the local inner classes even though the local inner class is defined inside the function.
Class Louter 1
Public void fun 1 ()
Float int j =30;
Class L inner 1
Public void fun L ()
System. Out. Prinln(“ inside fun L() of L Inner 1”);
System. Out. Prinln(x);
System. Out. Prinln(j);
} // end of funL ()
} \\ end of class Linner1
Linner l = new Linner 1 ();
- funL ();
System. Out. Prinln(“ inside fun 1()”);
Public static void main (string args [ ])
L outer l = new Louter 1();
Properties of Local inner classes:
- Local variables of a function are not accessible from the local inner classes even though local inner class is defined inside the function.
- Since the local inner class is local to a function, it is similar to local variables inside the function. So, all the rules of local variables apply to the local inner classes
- Thus, local inner classes cannot have any access specifier.
- Local constants of a function are accessible from its local inner class.
We cannot create
inner class inside the main of the outer class. If at all, we can create its object only inside the function in which it is defined.
Local Inner Class Homework Help
Tutorspoint.com USA online java experts offer live java programming homework help, Matlab programming assignment help, help with java programming assignment, Professional Java Assignment Help, Java Programming Help, java homework solutions at affordable price with high-quality work to students in countries like United States, Australia, Canada & United Kingdom