维生素e的功效与作用是什么| 金银花洗澡对婴儿有什么好处| 什么为力| 晚上喝蜂蜜水有什么好处和坏处| 梦见偷桃子是什么意思| 胆囊粗糙是什么意思| 银屑病为什么会自愈| 脚脖子肿是什么原因| 血清载脂蛋白b偏高是什么意思| 嗓子哑了吃什么药好| 羊水污染是什么原因造成的| 舌头痛吃什么药好得快| 淀粉酶高是什么原因| 357是什么意思| 尿素氮高吃什么药| 孕妇血糖高吃什么| 姗字五行属什么| 美尼尔综合征是什么原因引起的| 谷氨酸钠是什么| 吃什么掉秤快| 儿童喉咙痒咳嗽吃什么药| nec投影仪是什么牌子| 太平公主叫什么名字| 女同学过生日送什么礼物比较好| 什么网卡好| 少字五行属什么| 钟馗是什么意思| 天庭的动物是什么生肖| 来月经腰疼的厉害是什么原因| 梦见小蛇是什么意思| 春节为什么要放鞭炮| 什么是数位板| 经常胃疼是什么原因| 年轮稀疏的一面是什么方向| 阳痿什么意思| 什么叫精神分裂症| 脑袋痛什么原因| 月经期适合吃什么食物| 胆固醇高不可以吃什么食物| 做梦梦到自己拉屎是什么意思| 眼睛干涩模糊用什么眼药水| 沈阳有什么大学| 胃窦在胃的什么位置| 2029是什么年| 叶酸片有什么作用| 低碳生活是什么意思| 肤色不均匀是什么原因| 胎盘能吃吗有什么作用与功效| 交尾是什么意思| 10mg是什么意思| 卡拉是什么意思| 淋巴结肿大是什么样子的| 藕带是什么| 什么叫高危性行为| 尿路感染用什么药| 关节炎挂什么科| 感冒打什么针| 尿毒症有什么症状| 石化是什么意思| 双侧腋下见淋巴结什么意思| 甲醛中毒吃什么药解毒| 翌日什么意思| 康波是什么意思| 八月生日什么星座| 手足口病用什么药| 9.15是什么星座| 地级市市长什么级别| 嗳气打嗝吃什么药| 巾帼是指什么| 肝叶钙化灶是什么意思| 老树盘根是什么意思| 夏令时什么意思| 梦到吃蛇肉预示着什么| 为什么会有黑头| 圆脸适合什么刘海| 什么地响| miffy是什么意思| 手的皮肤黄是什么原因| 5.23是什么星座| 马上是什么意思| 梦见洗澡是什么意思| 吃苹果有什么好处| 猪血不能和什么一起吃| 己巳五行属什么| 是什么歌曲| 吃什么药头脑立刻清醒| 夏至有什么习俗| 鼹鼠是什么动物| 吃鸡是什么意思| 孩子生化了是什么意思| 命里缺什么怎么看| 甲沟炎是什么样子的| 做梦梦见棺材和死人是什么意思| 1990年什么生肖| 利湿是什么意思| 四海是什么意思| 血压高有什么表现| 胃功能三项检查是什么| 汇报是什么意思| 方脸适合什么耳环| 7月23日是什么日子| 福建有什么特产| 康复新液是什么做的| 痔疮不治会有什么危害| 枸杞泡酒有什么作用和功效| 阑尾炎能吃什么水果| 白斑不能吃什么| 为什么叫马桶| 鱼缸摆放什么位置最佳| 经常肚子疼拉肚子是什么原因| 性质是什么| 除服是什么意思| 为什么夏天热冬天冷| 网盘是什么东西| 女朋友生日送什么| 手肘黑是什么原因| 闭口粉刺是什么原因引起的| 大步向前走永远不回头是什么歌| 人丹是什么| 成人发烧38度吃什么药| 维生素c补什么| 回民为什么不吃猪肉| 酶是什么| 比热容是什么| 抽动症是什么引起的| hco3-是什么意思| 耳洞发炎用什么药| 梦见人头是什么征兆| 手麻是什么原因引起的| 年终奖是什么意思| 尿微肌酐比值高是什么情况| 静推是什么意思| 左旋肉碱是什么| 绝经三年了突然又出血了什么原因| 崴脚用什么药| 什么药治便秘最好最快| 前列腺钙化斑是什么意思| 人体缺硒会有什么症状| 过度什么意思| 什么人不能吃海参| 汗疱疹用什么药好| n标志的鞋子是什么牌子| 知我者非你也什么意思| clean什么意思| 什么是紫癜| 单是什么意思| spa是什么服务| 属蛇的人适合佩戴什么| 为什么熊猫是国宝| 两个方一个土是什么字| 砚字五行属什么| 维生素c的作用是什么| 脑梗复查挂什么科| 宫颈纳囊多发是什么意思| 多种维生素什么牌子的效果最好| 肖战是什么星座| 红景天是什么| 毛尖茶属于什么茶| 山楂什么时候成熟| 儿童肚子痛吃什么药| u型枕有什么作用| 耳石症挂什么科| 宣府是现在的什么地方| 千斤拔泡酒有什么功效| 女生问你喜欢她什么怎么回答| 嘱托是什么意思| 出大汗是什么原因| bl是什么单位| 蚕蛹过敏什么办法最快| 拔罐起水泡是什么原因| 什么不惧| 糖类抗原199是什么意思| 草字头加个弓念什么| 日本为什么要侵略中国| 莲子吃了有什么好处| 小孩子上户口需要什么证件| icp是什么| 粑粑是什么意思| 颇有是什么意思| 帅是什么意思| c反应蛋白高说明什么| 在编是什么意思| 红楼梦为什么是四大名著之首| 角是什么意思| 石女什么意思| 什么毛什么血| 市公安局局长是什么级别| 3月17日是什么星座的| 几何图形是什么| 眼睛红血丝用什么眼药水| 后嗣是什么意思| 筷子掉地上是什么征兆| 胎囊是什么| 父母都是o型血孩子是什么血型| 胆囊炎的症状是什么| 区人大代表是什么级别| 吃什么补充蛋白| 切克闹是什么意思| 铁皮石斛可以治什么病| 上火了吃什么食物降火| 为什么吹空调会咳嗽| 6月8号是什么星座| 闲是什么生肖| 肺癌晚期什么症状| 1963年发生了什么| 乙肝245阳性是什么意思| 牙龈和牙齿分离是什么原因| 舒张压是什么| 意大利面是用什么做的| 跟腱炎吃什么药效果好| 风湿性关节炎用什么药效果好| 薇诺娜适合什么年龄| 心血管疾病做什么检查| 心脏供血不足吃什么药| 什么长而什么| 肌肤之钥是什么档次| 儿童抽动症看什么科| 为什么不能送手表| 喜神是什么意思| 胰腺上长瘤意味着什么| 焖面用什么面条| puma是什么牌子| 尿道感染吃什么药最好| 忠心不二是什么生肖| 瑞夫泰格手表什么档次| 速度是70迈心情是自由自在什么歌| 胃肠感冒吃什么食物比较好| 四季更迭是什么意思| 五月份是什么季节| 肾宝片有什么副作用吗| 美业是什么| pof是什么意思| 为什么床上有蚂蚁| 腱鞘囊肿看什么科| 海藻糖是什么| 疖肿是什么样子的图片| m代表什么单位| 凌寒独自开的凌是什么意思| 头晕是为什么| 什么的变化| 满面红光是什么意思| 内裤发霉是什么原因| 八仙过海指什么生肖| 奈何桥是什么意思| 沉的右边念什么| 什么人容易得心梗| 翡翠是什么玉| 中暑喝什么好| 发际线是什么| 食管鳞状上皮增生是什么意思| 女团是什么意思| 六味地黄丸什么牌子好| 同房出血要做什么检查| 手掌发热是什么原因| 林彪为什么要叛逃| 跨界是什么意思| 手麻是什么引起的| 肝内低密度影是什么意思| 耳心痒是什么原因| 可逆是什么意思| 副乳是什么原因造成的| 单抗是什么药| 酸枣仁配什么治疗失眠| 低血压高是什么原因| 百度Jump to content

什么什么的天空

From Wikipedia, the free encyclopedia
百度 □蒋理(学者)

A Java package organizes Java classes into namespaces,[1] providing a unique namespace for each type it contains. Classes in the same package can access each other's package-private and protected members.

In general, a package can contain the following kinds of types: classes, interfaces, enumerations, records and annotation types. A package allows a developer to group classes (and interfaces) together. These classes will all be related in some way – they might all have to do with a specific application or perform a specific set of tasks. Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality.

Using packages

[edit]

In a Java source file, the package that this file's class or classes belong to is specified with the package keyword. This keyword is usually the first keyword in the source file. At most one package declaration can appear in a source file.

package java.awt.event;

To use a package's classes inside a Java source file, it is convenient to import the classes from the package with an import declaration. The following declaration

import java.awt.event.*;

imports all classes from the java.awt.event package, while the next declaration

import java.awt.event.ActionEvent;

imports only the ActionEvent class from the package. After either of these import declarations, the ActionEvent class can be referenced using its simple class name:

ActionEvent myEvent = new ActionEvent();

Classes can also be used directly without an import declaration by using the fully qualified name of the class. For example,

java.awt.event.ActionEvent myEvent = new java.awt.event.ActionEvent();

does not require a preceding import declaration.

Package-wide Javadoc & annotations

[edit]

Documentation explaining the package as a whole is written as Javadoc in a file named exactly `package-info.java`. That file is also the place for annotations to be used across all classes of the package.[2]

The unnamed package

[edit]

If a package declaration is not used, classes are placed in an unnamed package. Classes in an unnamed package cannot be imported by classes in any other package.[3] The official Java Tutorial advises against this:

Generally speaking, an unnamed package is only for small or temporary applications or when you are just beginning the development process. Otherwise, classes and interfaces belong in named packages.[4]

Package access protection

[edit]

Public members and classes are visible everywhere and private members are visible only in the same class. Classes within a package can access classes and members declared with default (package-private) access as well as class members declared with the protected access modifier. Default (package-private) access is enforced when a class or member has not been declared as public, protected or private. By contrast, classes in other packages cannot access classes and members declared with default access. However, class members declared as protected can be accessed from the classes in the same package as well as classes in other packages that are subclasses of the declaring class.[5]

Creation of JAR files

[edit]

JAR files are created with the jar command-line utility. The command

jar cf myPackage.jar *.class

compresses all .class files into the JAR file myPackage.jar. The 'c' option on the command line tells the jar command to "create new archive." The ' f ' option tells it to create a file. The file's name comes next before the contents of the JAR file.

Package naming conventions

[edit]

Packages are usually defined using a hierarchical naming pattern, with some levels in the hierarchy separated by periods (., pronounced "dot"). Although packages lower in the naming hierarchy are often referred to as "subpackages" of the corresponding packages higher in the hierarchy, there is almost no semantic relationship between packages. The Java Language Specification establishes package naming conventions to avoid the possibility of two published packages having the same name. The naming conventions describe how to create unique package names, so that packages that are widely distributed will have unique namespaces. This allows packages to be separately, easily and automatically installed and catalogued.

In general, a package name begins with the top level domain name of the organization and then the organization's domain and then any subdomains, listed in reverse order. The organization can then choose a specific name for its package. Subsequent components of the package name vary according to an organization's own internal naming conventions.[6]

For example, if an organization in Canada called MySoft creates a package to deal with fractions, naming the package ca.mysoft.fractions distinguishes the fractions package from another similar package created by another company. If a German company named MySoft also creates a fractions package, but names it de.mysoft.fractions, then the classes in these two packages are defined in a unique and separate namespace.

Complete conventions for disambiguating package names and rules for naming packages when the Internet domain name cannot be directly used as a package name are described in section 7.7 of the Java Language Specification.[7]

Core packages in Java SE 8

[edit]
java.lang Basic language functionality and fundamental types. Implicitly imported by every program.
java.util Collection data structure classes
java.io File operations
java.math Multiprecision arithmetics
java.nio The Non-blocking I/O framework for Java
java.net Networking operations, sockets, DNS lookups, ...
java.security Key generation, encryption and decryption
java.sql Java Database Connectivity (JDBC) to access databases
java.awt Basic hierarchy of packages for native GUI components
java.text Provides classes and interfaces for handling text, dates, numbers, and messages in a manner independent of natural languages.
java.rmi Provides the RMI package.
java.time The main API for dates, times, instants, and durations.
java.beans The java.beans package contains classes and interfaces related to JavaBeans components.
java.applet This package provides classes and methods to create and communicate with the applets.

Modules

[edit]

In Java 9 (released on September 21, 2017) support for "modules", a kind of collection of packages, was implemented as a result of the development effort of Project Jigsaw. The "modules" were earlier called "superpackages" and originally planned for Java 7.

Modules describe their dependencies in a declaration placed in a file named module-info.java at the root of the module's source-file hierarchy. Since Java 9, the JDK is able to check the module dependencies both at compile time and runtime. The JDK itself is modularized for Java 9.[8][9] For example, the majority of the Java standard library is exported by the module java.base.

As an example, the following module declaration declares that the module com.foo.bar depends on another com.foo.baz module, and exports the following packages: com.foo.bar.alpha and com.foo.bar.beta:

module com.foo.bar {
    requires com.foo.baz;

    exports com.foo.bar.alpha;
    exports com.foo.bar.beta;
}

See also

[edit]

References

[edit]
  1. ^ James Gosling, Bill Joy, Guy Steele, Gilad Bracha, The Java Language Specification, Third Edition, ISBN 0-321-24678-0, 2005. In the Introduction, it is stated "Chapter 7 describes the structure of a program, which is organized into packages similar to the modules of Modula."
  2. ^ "Chapter 7. Packages and Modules". docs.oracle.com. Retrieved 2025-08-06.
  3. ^ "Chapter 7. Packages". Docs.oracle.com. Retrieved 2025-08-06.
  4. ^ "Creating and Using Packages (The Java? Tutorials > Learning the Java Language > Packages)". docs.oracle.com.
  5. ^ "Controlling Access to Members of a Class (The Java? Tutorials > Learning the Java Language > Classes and Objects)". docs.oracle.com.
  6. ^ Code Conventions for the Java Programming Language: 9. Naming Conventions
  7. ^ "Packages". docs.oracle.com.
  8. ^ "JDK Module Summary". Oracle Corporation. 2025-08-06. Archived from the original on 2025-08-06. Retrieved 2025-08-06.
  9. ^ "Understanding Java 9 Modules". Oracle Corporation. October 1, 2017. Retrieved 2025-08-06.
[edit]
脚上长水泡是什么原因 灯火葳蕤是什么意思 八一年属什么生肖 什么的飞机 227什么意思
意味深长是什么意思 什么止疼药见效最快 梦见着火了是什么意思 腿麻是什么病的前兆吗 一直打嗝不止是什么原因
胎心停了会有什么症状 腹泻可以吃什么 三尖瓣轻度反流说明什么 外甥是什么关系 应用心理学是什么
什么是理数 支付宝账号是什么 曼陀罗是什么 胃萎缩是什么意思 阿胶烊化是什么意思
胆固醇高吃什么可以降下来hcv9jop5ns6r.cn 世界上什么东西最大hcv8jop1ns6r.cn 什么是骨癌hcv7jop7ns1r.cn 四季如春是什么生肖sanhestory.com 心脏不好最忌讳吃什么shenchushe.com
猫毛过敏吃什么药hcv8jop5ns9r.cn 红色属于五行属什么jingluanji.com 肛肠科属于什么科hcv9jop7ns3r.cn 8月5日是什么星座naasee.com 月经期间适合吃什么食物hcv9jop0ns6r.cn
元参别名叫什么hcv8jop8ns3r.cn 凝血功能差有什么危害hcv7jop5ns5r.cn 世界上最难的字是什么hcv8jop4ns7r.cn 冰晶是什么hcv9jop0ns1r.cn 丁火是什么火hcv7jop6ns9r.cn
车厘子与樱桃有什么区别hcv8jop8ns1r.cn 肾结石都有什么症状hcv7jop9ns8r.cn 包皮瘙痒用什么药hcv9jop6ns8r.cn 夏天吃什么菜最好hcv8jop5ns0r.cn 减肥期间吃什么好hcv8jop7ns8r.cn
百度