Force invocation of base class method

后端 未结 4 1212
孤城傲影
孤城傲影 2020-12-12 00:11

The following code when run obviously prints out \"B1/A2/B2\". Now, is it possible for it to print \"A1/A2/B2\" instead (i.e. A#method2() should invoke method1() on A, not

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 00:38

    You could also make the A.method1 private. Then, even if you have B.method1, A.method1 will be called instead. But I'm not sure about that, you should check

提交回复
热议问题