Java method().method().method(); How to do this?



例如我该怎么做?

getServer().getManager().registerNewUser(arguments);

getServer().getStats().user(arguments);

像这样的东西,我尝试过搜索网络,但我找不到任何关于这个的教程,所以我在这里问。

在 OOP 中,一般来说,这个概念被称为类组合,你可以在这里找到它 https://en.wikipedia.org/wiki/Object_composition

同样对于java以及组合和继承之间的区别 https://www.baeldung.com/java-inheritance-composition

相关内容

最新更新