Java 9 sub-packages split across modules

半腔热情 提交于 2019-12-04 02:22:11

问题


In Java 9, can I split sub-packages across modules? For example, can I have com.example.foo in one module and com.example.foo.bar in another module?

This seems like a simple question, but for some reason I'm not able to find a direct answer after some searching. An authoritative reference would be appreciated.

I assume I can have sibling sub-packages in different modules, e.g. com.example.foo and com.example.other.


回答1:


There's no such thing as a "sub-package". my.package and my.package.sub have nothing more in common than any two random packages: they just have similar names. See this answer which starts

In reality there is no such thing as a sub-package in Java

That being the case, yes you can include them in different modules.



来源:https://stackoverflow.com/questions/50889780/java-9-sub-packages-split-across-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!