Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在无接口导入中的函数调用上运行函数?例如,如果我要导入库,是否有可能每次调用其函数 foo 时,都会调用我的函数 bar也?谢谢
如果您可以编辑您的代码并且foo驻留的类不是最终的,您也可以覆盖该类的foo调用bar:
foo
bar
class MyFooClass extends FooClass{ @Override void foo(){ bar(); //Not sure if you want bar to be static or not, or if you want bar first or last. super.foo(); } }
然后只需在整个代码中使用MyFooClass而不是。FooClass
MyFooClass
FooClass