• <legend id='M59pN'><style id='M59pN'><dir id='M59pN'><q id='M59pN'></q></dir></style></legend>
    <tfoot id='M59pN'></tfoot>

  • <small id='M59pN'></small><noframes id='M59pN'>

    • <bdo id='M59pN'></bdo><ul id='M59pN'></ul>

    1. <i id='M59pN'><tr id='M59pN'><dt id='M59pN'><q id='M59pN'><span id='M59pN'><b id='M59pN'><form id='M59pN'><ins id='M59pN'></ins><ul id='M59pN'></ul><sub id='M59pN'></sub></form><legend id='M59pN'></legend><bdo id='M59pN'><pre id='M59pN'><center id='M59pN'></center></pre></bdo></b><th id='M59pN'></th></span></q></dt></tr></i><div id='M59pN'><tfoot id='M59pN'></tfoot><dl id='M59pN'><fieldset id='M59pN'></fieldset></dl></div>

        在 Java 文件中定义包的目的是什么?

        时间:2023-09-27
          <tbody id='17zTM'></tbody>

      1. <i id='17zTM'><tr id='17zTM'><dt id='17zTM'><q id='17zTM'><span id='17zTM'><b id='17zTM'><form id='17zTM'><ins id='17zTM'></ins><ul id='17zTM'></ul><sub id='17zTM'></sub></form><legend id='17zTM'></legend><bdo id='17zTM'><pre id='17zTM'><center id='17zTM'></center></pre></bdo></b><th id='17zTM'></th></span></q></dt></tr></i><div id='17zTM'><tfoot id='17zTM'></tfoot><dl id='17zTM'><fieldset id='17zTM'></fieldset></dl></div>

      2. <small id='17zTM'></small><noframes id='17zTM'>

          <tfoot id='17zTM'></tfoot>
            • <bdo id='17zTM'></bdo><ul id='17zTM'></ul>
                <legend id='17zTM'><style id='17zTM'><dir id='17zTM'><q id='17zTM'></q></dir></style></legend>

                  本文介绍了在 Java 文件中定义包的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我是一个新手,刚刚知道如果我定义说的话

                  I am a newbie and just learned that if I define say

                  package my.first.group.here;
                  ...
                  

                  那么这个包中的Java文件将被放在my/first/group/here目录下.

                  then the Java files that are in this package will be placed under my/first/group/here directory.

                  将一些 Java 文件放在一个包中的主要目的是什么?另外,如果我选择采用这个,我应该如何将它们分组?

                  What is the main purpose of putting some Java files in a package? Also, if I choose to adopt this, how should I group them?

                  谢谢

                  对于任何可能再次遇到相同问题的人,我刚刚发现 这个关于软件包的教程来自 Sun.

                  For anyone who might have the same question again, I just found this tutorial on packages from Sun.

                  推荐答案

                  让我们从Java 包"的定义开始,如 维基百科文章:

                  Let's start with the definition of a "Java package", as described in the Wikipedia article:

                  Java 包是一种机制将 Java 类组织成类似于模块的命名空间模数.Java包可以存储在称为 JAR 文件的压缩文件,允许类下载速度更快一组而不是一次一个.程序员通常还使用用于组织类的包到同一类别或提供类似的功能.

                  A Java package is a mechanism for organizing Java classes into namespaces similar to the modules of Modula. Java packages can be stored in compressed files called JAR files, allowing classes to download faster as a group rather than one at a time. Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality.

                  因此,基于此,Java 中的包只是一种用于组织类和防止类名冲突的机制.您可以随意命名它们,但 Sun 发布了一些 命名约定 您在命名包时应该使用:

                  So based on that, packages in Java are simply a mechanism used to organize classes and prevent class name collisions. You can name them anything you wish, but Sun has published some naming conventions that you should use when naming packages:

                  唯一包名的前缀是始终以全小写 ASCII 书写字母,应该是其中之一顶级域名,目前为com,edu、gov、mil、net、org 或其中之一英文两字母代码识别ISO 标准中指定的国家3166, 1981.

                  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.sun.eng

                  com.apple.quicktime.v2

                  com.apple.quicktime.v2

                  edu.cmu.cs.bovik.cheese

                  edu.cmu.cs.bovik.cheese

                  这篇关于在 Java 文件中定义包的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java 包 com 和 org 下一篇:(Java)包组织有最佳实践吗?

                  相关文章

                  最新文章

                1. <legend id='BcC8h'><style id='BcC8h'><dir id='BcC8h'><q id='BcC8h'></q></dir></style></legend>

                  1. <tfoot id='BcC8h'></tfoot>
                    <i id='BcC8h'><tr id='BcC8h'><dt id='BcC8h'><q id='BcC8h'><span id='BcC8h'><b id='BcC8h'><form id='BcC8h'><ins id='BcC8h'></ins><ul id='BcC8h'></ul><sub id='BcC8h'></sub></form><legend id='BcC8h'></legend><bdo id='BcC8h'><pre id='BcC8h'><center id='BcC8h'></center></pre></bdo></b><th id='BcC8h'></th></span></q></dt></tr></i><div id='BcC8h'><tfoot id='BcC8h'></tfoot><dl id='BcC8h'><fieldset id='BcC8h'></fieldset></dl></div>

                        <bdo id='BcC8h'></bdo><ul id='BcC8h'></ul>

                      <small id='BcC8h'></small><noframes id='BcC8h'>