Access Outer Class this instance

后端 未结 2 1060
长情又很酷
长情又很酷 2020-12-20 11:23

how do we access outer class this instance: eg in

Class A {

   Class B {

      this.helloB();
      (A\'s this).hello()
   }
}

how do we

相关标签:
2条回答
  • 2020-12-20 11:55

    Just call

    A.this.hello()
    
    0 讨论(0)
  • 2020-12-20 11:55

    By prefixing this with the class: A.this.hello()

    Similarly, when you want to create an instance of B outside of A, you can use a.new B() (where a instanceof A == true).

    0 讨论(0)
提交回复
热议问题