1. Create an inner class.
  2. Create an object of inner class.
  3. Access class members of inner class.
  4. Identify the inner class by reading the name of .class file.

Create and Access Inner Class in JAVA Video Tutorial (Hindi)

Vineet Agrawal

Published on January 5, 2017

1. Inner class comes under the scope of another class.
2. Syntax of object declaration of inner class is

<Outer_Class>.<Inner_Class>

3. Syntax of instantiation of inner class object is

new <Outer Class Constructor>. new <Inner Class Constructor>

4. Name of .class file of inner class is like

<outer_class_name>$<inner_class_name> 

Source code used in the program


class outer
   {
void display()
{
System.out.println("outer");
}
class inner
{
void display()
{
System.out.println("Inner class");
}
}
public static void main(String args[])
{
outer o = new outer();
o.display();
outer.inner in = new outer().new inner();
in.display();
}
}