问题描述
在JRE中,Sun的内部软件包以2个顶级域名(sun和com)为前缀。例如,
In JRE, Sun's internal packages are prefixed with 2 top-level domains (sun and com). For example,
com.sun.security.jgss
sun.security.jgss
对我来说,他们选择的前缀似乎很随机。我很好奇Sun使用什么规则。
It seems pretty random to me which prefix they choose. I am curious what rules Sun uses for this.
推荐答案
com.sun约定是更可取的格式,因为它遵循为命名Java包而建立的命名约定。
The "com.sun" convention is the more preferable format because it follows the "naming conventions" that have been established for naming Java packages.
您应该使用您的唯一公司或个人网站URL作为包中的前几个单词,以保证名称空间中的唯一性。以太阳开头的那些可能并不打算暴露给外界。
You're supposed to use your unique company or personal website URL as the first few words in the package to guarantee uniqueness in the namespace. The ones that start with "sun" were probably not intended to be exposed to the outside world.
这篇关于Sun的Java包命名约定:sun vs. com.sun的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!