How can I access a method that is inside a class that is inside another method of another class in Java

Viewed 71

Below is the program which compiles successfully but how do I access m2() method of class B that is inside m1() method of class A.

class A{  
    public void m1()
    {
      System.out.println("A-m1"); 
        class B{
            public void m2()
            {
                System.out.println("B-m2");
            }
        }//end of class B
    }//end of m1() method
}// end of class A
2 Answers
Related