Java Member Inner Class


To write a non-static class within a class, but outside a method is known as a member inner class.

Syntax:

 class OuterClass {
	// data member and method
   class InnerClass {
   	// data member and method
   }
}

Example

 public class Outerclass{  
    private int Age=30;  
    class Innerclass{  
        void showdata(){
            System.out.println("Age is "+Age);
        }  
    }  
    public static void main(String args[]){  
        Outerclass oc=new Outerclass();  
        Outerclass.Innerclass ic=oc.new Innerclass();  
        ic.showdata();  
    }  
} 



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.