[Java] Inner Class

Inner class is declared in class 1 other class. VD class declared in class Inner Outer
The method in Outer class can declare objects of class Inner normally.
However these methods in other classes par with class must declare Import Outer Outer class or declare as follows:
Outer.Inner out = new Outer().new Inner();

Code illustrations:

//Inner class là class được khai báo trong class khác.

class InnerClass{
	public static void main(String [] args){
		Outer out = new Outer();	// tạo 1 đối tượng của class Outer
		out.outerShow();	//thực hiện phương thức outerShoư().
		
		MyClass myOut = new MyClass();	//tạo 1 đối tượng của MyClass
		myOut.myShow();	//thực hiên phương thức myShow().
	}
}

class Outer{
	public void outerShow(){
		Inner inner = new Inner();	//tạo đối tượng Inner cùng nằm trong class Outer
		inner.innerShow();
	}
	class Inner{		//Class Inner nằm trong class Outer
		public void innerShow(){
			System.out.println("This is Inner class.");
		}
	}
}

class MyClass{
	public void myShow(){
		//tạo 1 đối tượng của class Inner trong 1 class ngang hàng với class Outer chứa class Inner
		Outer.Inner out = new Outer().new Inner();	
		System.out.print("MyClass call Inner : ");
		out.innerShow();
	}
}