Last Updated: 20 August, 2022
A Java class that is defined inside a block or method is known as a "local inner class" or "method local in class" in Java. The scope of the local inner class is inside the block or method only; it can’t be accessed from outside the block or method in which it is defined.
A local inner class cannot be declared as public, protected, private, or static, but it can be declared as final, abstract, and strictfp.
Syntax of Local Inner Class
The local inner class can access the outer class properties such as fields and methods.
A method local inner class can extend an abstract class or implement an interface.
Output
Outer class -> showNumber() method started....
LocalInnerClass class -> displayNumber() method
minNum: 50
maxNum: 100
avgNum: 75
totalNum: 100
Outer class -> showNumber() method ended....
What compiler does at compile time:
When we compile the above Java program, after successful compilation, the compiler generates three .class files for the each classes. These files are named by the compiler as:
👉 Before Compilation
👉 After Compilation
That's all guys, hope this Java article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com