Java com.*软件包名称空间 [英] Java com.* package namespace

查看:41
本文介绍了Java com.*软件包名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经常看到com.*软件包名称空间."com"是什么意思?谢谢.

It's quite often to see com.* package namespace. What does 'com' mean? Thanks.

推荐答案

在JLS中指定了包的命名约定.这是相关的代码段(本节中有很多内容):

The naming convention for packages is specified in the JLS. Here is the relevant snippet (there's a lot more in the section):

您首先要拥有(或属于拥有)互联网域名(例如 sun.com )的组织,从而形成唯一的软件包名称.然后,您逐个组件颠倒此名称,以获得本示例中的 com.sun ,并将其用作包名称的前缀,并使用组织内部开发的约定来进一步管理包名称.

You form a unique package name by first having (or belonging to an organization that has) an Internet domain name, such as sun.com. You then reverse this name, component by component, to obtain, in this example, com.sun, and use this as a prefix for your package names, using a convention developed within your organization to further administer package names.

在Sun代码的命名约定部分中也有提供约定文件:

It's also given in Naming Conventions section of Sun's code conventions document:

软件包:唯一的软件包名称的前缀始终以全小写ASCII字母书写,并且应该是顶级域名之一,当前为 com edu gov mil net org 或英语之一两个字母的代码,用于标识1981年ISO标准3166中指定的国家/地区.

Packages: The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.

包名称的后续组成部分会根据组织内部的内部命名约定而有所不同.这样的约定可能会指定某些目录名称组成部分是部门,部门,项目,计算机或登录名.

Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.

示例: com.sun.eng com.apple.quicktime.v2 edu.cmu.cs.bovik.cheese


因此,包名称中的 com.前缀与 相同.com 域名后缀:"commercial".


So com. prefix in package names means the same as .com suffix in domain names: "commercial".

这篇关于Java com.*软件包名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆