gpt4 book ai didi

eclipse - Eclipse 中的包和项目有什么区别?

转载 作者:行者123 更新时间:2023-12-02 04:09:39 25 4
gpt4 key购买 nike

我真的不明白拥有一个包有什么意义。每个类都保存在不同的文件中,那么在单个项目中使用不同的包有什么意义呢?

最佳答案

Eclipse 项目与 Java 无关。它是 Eclipse 的一项功能,用于组织和配置不同的项目。

Java 包是 Java 的一种语言功能。您可以使用它们来构建项目并控制不同类之间的可见性。即使在相对较小的项目中(可能已经有几百个类),这也是必要的。我建议您查找有关 Java 包是什么以及它可以做什么的基本教程。为了给您一个良好的开端,以下是 official documentation 的内容。不得不说一下将相关类捆绑在一个包中的目的:

You should bundle these classes and the interface in a package for several reasons, including the following:

  • You and other programmers can easily determine that these types are related.
  • You and other programmers know where to find types that can provide graphics-related functions.
  • The names of your types won't conflict with the type names in other packages because the package creates a new namespace.
  • You can allow types within the package to have unrestricted access to one another yet still restrict access for types outside the package.

关于eclipse - Eclipse 中的包和项目有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43919764/

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