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.

Example:

Class Louter 1

{

Int x;

Public void fun 1 ()

{

Int I;

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 ();

  1. funL ();

System. Out. Prinln(“ inside fun 1()”);

}

Public static void main (string args [ ])

{

L outer    l = new Louter 1();

  1. funL();

}

}

Properties of Local inner classes:

  1. Local variables of a function are not accessible from the local inner classes even though local inner class is defined inside the function.
  2. 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
  3. Thus, local inner classes cannot have any access specifier.
  4. Local constants of a function are accessible from its local inner class.
  5. We cannot create

    object

    of

    local

    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