You are doing a great job mentioning where the questions come from Jothi
B is an inner class (non-static nested class) of A so it needs an instance of A to exist before an instance of B can exist. So that's what the new A() is for - to get the outer instance of A. Now we can use our instance of A to create an instance of B. The
Java syntax for that is new A().new B(). So now we have our instance of B together with its containing instance of A. We can now call B's methods on this instance of B. So new A().new B().m1() calls method m1 on an instance of inner class B contained in an instance of A.
I feel rather dizzy now.