gpt4 book ai didi

java - 独立程序包

转载 作者:行者123 更新时间:2023-11-30 06:08:47 25 4
gpt4 key购买 nike

我对 Java 还很陌生,我知道包的作用。您可以使用它们对 Java 应用程序的多个文件进行排序。但是,如果您的应用程序只有一个类,那么将其放在包中是标准的吗?这样做的优点和缺点是什么?

编辑:我将这个单个类打包到 .jar 中之后文件。

最佳答案

来自oracle documentation ,显然

The primary motivation for jar development was so that Java applets and their requisite components (.class files, images and sounds) can be downloaded to a browser in a single HTTP transaction, rather than opening a new connection for each piece. This greatly improves the speed with which an applet can be loaded onto a web page and begin functioning. The JAR format also supports compression, which reduces the size of the file and improves download time still further. Additionally, individual entries in a JAR file may be digitally signed by the applet author to authenticate their origin.

来自Package Documentation of Oracle ,

For small programs and casual development, a package can be unnamed (§7.4.2) or have a simple name, but if code is to be widely distributed, unique package names should be chosen using qualified names. This can prevent the conflicts that would otherwise occur if two development groups happened to pick the same package name and these packages were later to be used in a single program.

关于java - 独立程序包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39273936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com