Javatpoint Logo
Javatpoint Logo

Java Member inner class

A non-static class that is created inside a class but outside a method is called member inner class.


Java Member inner class example

In this example, we are creating msg() method in member inner class that is accessing the private data member of outer class.

Test it Now


data is 30

Internal working of Java member inner class

The java compiler creates two class files in case of inner class. The class file name of inner class is "Outer$Inner". If you want to instantiate inner class, you must have to create the instance of outer class. In such case, instance of inner class is created inside the instance of outer class.

Internal code generated by the compiler

The java compiler creates a class file named Outer$Inner in this case. The Member inner class have the reference of Outer class that is why it can access all the data members of Outer class including private.

Let's Work Together!

Javatpoint is passionate to offer better content to the world. Please mail your contribution to We will show your name and create your user profile. You can contribute the following things:
  • Article on Any Topic (which is not available on Javatpoint)
  • Your Interview Experience on Company
  • Company Interview Questions with Answers
  • Recruitment Process of Company
  • Programs, and Algorithm
  • Videos
  • Test Paper
  • Improve Article

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials