-2
 interface Hello {
   abstract class A {
     void show() {
       B b = new B();
       b.dis();
     }
    }
    class B {
      void dis() {
        System.out.println("HIiiiiiiii");
      }
    }
 }

But this is not working please any one guide me how I can access this because this requirement should not be changed..

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268

1 Answers1

1

If I'm reading the question correctly, you want the following:

new Hello.B().dis();
new Hello.A(){}.show();

where new Hello.A(){} instantiates an anonymous subclass of the abstract class A.

Edit

If B is defined inside A, then you'd want:

(new Hello.A(){}.new B()).dis();
new Hello.A(){}.show();

Where the dis() call looks the way it does because B will no longer be an implicitly static inner class, so it will need an instance of A.

Vlad
  • 18,195
  • 4
  • 41
  • 71