四个人念什么| 男人额头有痣代表什么| 看灰指甲挂什么科| 正县级是什么级别| 乔迁送什么| 汞中毒有什么症状| 甲鱼和乌龟有什么区别| 什么东西补铁| 早上起床眼睛浮肿是什么原因| 女生自慰什么感觉| 孕妇适合喝什么牛奶| 福禄寿是什么意思| 一戴套就软是什么原因| 什么去湿气| 草字头弓读什么字| 肌肉代偿是什么意思| 多喝水有什么好处坏处| 悱恻是什么意思| 气血是什么意思| 腰椎mri是什么检查| 怕金病帕金森是什么症状| 雌二醇测定是什么检查| 1998年属虎是什么命| 节制的意思是什么| 15一16岁青少年腰疼是什么病| 玫瑰疹是什么病| 浮想联翩是什么意思| 上梁是什么意思| 新生儿一直哭闹是什么原因| 味精吃多了有什么危害| 什么是回避型依恋人格| vpc是什么| 什么是文员| 胸疼挂什么科室| 走路快的人是什么性格| 女生安全期什么意思| 土羊是什么字| 梦见死人了是什么意思| 掉头发缺少什么维生素| 男生为什么会晨勃| 怕冷吃什么药| 槟榔中间的膏是什么| 半盏流年是什么意思| 女人没经验开什么店好| 入睡困难吃什么药效果最好| 一代宗师是什么意思| 乌龙茶属于什么茶| 一度电是什么概念| 无用功是什么意思| 头秃了一块是什么原因| 忽必烈和成吉思汗是什么关系| 结核有什么症状| 蓁字五行属什么| 90年出生属什么生肖| 胆汁什么颜色| 青春期指什么年龄段| smt是什么意思| 什么星座最聪明| 两只小船儿孤孤零零是什么歌| 阴道炎要用什么药| 肺炎吃什么消炎药| 世界上最大的鸟是什么鸟| 长智齿意味着什么| 内推是什么意思| 安宫牛黄丸有什么作用| 生姜能治什么病| 云南白药治什么| 晚上为什么不能剪指甲| 手抖挂什么科室| 髻是什么意思| 盗墓笔记的结局是什么| 什么是情人| 卵巢畸胎瘤是什么病| 女人熬夜吃什么抗衰老| sport是什么意思| 独角戏什么意思| 梦见搬家是什么预兆| 伤口不容易愈合是什么原因| 外感风热是什么意思| 什么什么之财| 梅菜扣肉的梅菜是什么菜| 老是犯困想睡觉是什么原因| 耳顺是什么意思| 己卯日五行属什么| 拔萝卜什么意思| 红肉指的是什么肉| 妇科假丝酵母菌是什么病| 11月16是什么星座| 静脉曲张是什么样子| p图是什么意思| 虎皮兰开花寓意什么| 包饺子是什么意思| 子宫内膜单纯性增生是什么意思| 性质是什么意思| 鳏寡孤独是什么意思| 旋转跳跃我闭着眼是什么歌| 三七粉主要治疗什么病| 己卯日五行属什么| 白露是什么季节的节气| 学痞是什么意思| 杀马特什么意思| 小孩拉肚子应该吃什么食物好| 狗狗吐是什么原因| 甲胎蛋白是什么| 卷帘大将是干什么的| 玫瑰花茶和什么搭配好| kerry英文名什么意思| 出马什么意思| ccb是什么药物| 胰腺在人体起什么作用| 种植牙有什么危害| 射手座女和什么星座最配| 肝郁脾虚吃什么药效果最好| 蜂蜜什么时候喝最佳| 什么是便血| kappa属于什么档次| 碘伏是什么| 巨大的什么| 脂肪肝用什么药物治疗| 牙疼是什么原因| 胸口疼痛吃什么药| 胆固醇高不能吃什么| 岔气是什么症状| 摇滚是什么意思| 内火旺是什么原因| 甘油三酯高吃什么| 艾灸治什么病| 百折不挠指什么生肖| 小三阳有什么症状表现| 缺钠有什么症状和危害| 隐身是什么意思| 什么是风寒感冒| 激素药是什么意思| 晚上吃什么不发胖| 空调睡眠模式是什么意思| 吕布的武器叫什么| 草果长什么样| 艾灸后痒是什么原因| 古丽是什么意思| 什么叫杵状指| 指鼻试验阳性代表什么| 睾丸积液吃什么药最好| apc药片是什么药| 什么的仪式| 眼睛怕光是什么原因| 腹透是什么意思| 眼睑肿是什么原因| 宝宝低烧是什么原因引起的| 1878年属什么生肖| 乌鸡炖什么好吃| 12月5号是什么星座| 夏天盖什么被子最舒服| 牙龈萎缩用什么牙膏| 鲱鱼罐头为什么这么臭| 玉米什么时候传入中国| 豆沫是什么做的| 2.16什么星座| 银杏叶子像什么| 武夷山岩茶属于什么茶| 缺锌容易得什么病| 世界上最大的数是什么| 软绵绵的什么| 后背容易出汗是什么原因| 存是什么生肖| 血管瘤吃什么药| 梦见蛇被别人打死是什么兆头| 微信上面有个耳朵是什么意思| 养尊处优的意思是什么| 女孩名字带什么字好听| 什么得直什么| 玛瑙是什么材质| 手肿胀是什么原因| 斯夫是什么意思| 右手手指头麻木是什么病的前兆| 林格液又叫什么| 乳腺病人吃什么好| 势不可挡是什么意思| 火气旺盛有什么症状| 五粮液是什么香型的酒| 喝啤酒头疼是什么原因| 鸡蛋与什么食物相克| 一九七二年属什么生肖| 什么快递可以寄宠物| 补肾吃什么药效果最好| 二月十八是什么星座| 喝酒上头是什么原因| 一什么商店| 皮毒清软膏有什么功效| 刻章需要什么材料| 什么是维生素| 言重了是什么意思| 肾综合征是什么病严重吗| 精液发黄是什么原因| 梦见自己爷爷死了是什么预兆| 豆种翡翠属于什么档次| 巳火是什么火| 上眼皮浮肿是什么原因| 屁股右边痛是什么原因| 输卵管堵塞吃什么药可以疏通| 肾囊肿是什么原因引起的| 酉时是什么时候| 怀孕初期吃什么| 茵陈和什么泡水喝对肝脏最好| 决定的近义词是什么| 什么是公历年份| 油烟机什么牌子好| 大脑镰钙化灶是什么意思| 烤鱼用什么鱼| c2是什么车型| 涵字五行属什么| 精工手表什么档次| 不走心是什么意思| 哈伦裤配什么鞋子好看| 很什么很什么| 脚崴了挂什么科| 心跳不规律是什么原因| 降血脂吃什么食物| tips是什么意思| 实性结节什么意思| 舌头疼吃什么药| 花生不能和什么食物一起吃| 为什么天天做梦| 脑梗是什么病| 毛周角化症是什么原因引起的| 8.26是什么星座| 西边五行属什么| 肺上有结节是什么意思| 慢阻肺是什么原因引起的| 什么什么致志| 奶篓子是什么意思| 化疗后白细胞低吃什么补得快| 做爱吃什么药| 2017年属鸡火命缺什么| 4.22是什么日子| 以逸待劳是什么意思| 一什么大厦| 今天出生的男宝宝取什么名字好| 五花八门是什么意思| 做什么运动可以长高| 男性尿出血什么原因| cdts什么意思| 多囊肾是什么意思| 什么是标准差| 1.29是什么星座| 为什么不孕不育| 眼睛长黄斑是什么原因| 劝君更尽一杯酒的下一句是什么| 美缝剂什么牌子的好| 画地为牢下一句是什么| 皮肤长癣是什么原因| 喝黑苦荞茶有什么好处和坏处| 温州有什么区| 花雕酒是什么酒| 背德感是什么意思| ag医学上是什么意思| 金牛座什么性格| 白细胞低吃什么补得快| 性激素是什么| 九斗一簸箕有什么说法| 57属什么生肖| 尿酸降低是什么意思| 有口臭是什么原因| 猪血和鸭血有什么区别| 为什么白醋把纹身洗掉了| 百度Jump to content

这位2B小姐姐一定是打了Mod!一周大师级COS精选

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]
范畴的意思是什么 胚由什么组成 脸大适合什么发型 盍是什么意思 看肝脏挂什么科
none是什么意思 37岁属什么的生肖 昆仑山在什么地方 喉咙有浓痰是什么原因 血沉是什么意思
什么玉最好有灵性养人 classy是什么意思 内页是什么意思 打完耳洞要注意什么 牙齿深覆合是什么意思
公章一般是什么字体 vae是什么意思 冷感冒吃什么药好得快 霖五行属什么 血液凝固快是什么原因
阳历八月份是什么星座hcv8jop6ns0r.cn 无药可救是什么意思hcv8jop2ns5r.cn 阳痿早泄吃什么药最好naasee.com 肺积水是什么病hcv7jop5ns4r.cn 举足轻重是什么生肖hcv9jop4ns7r.cn
rsp是什么意思520myf.com 维生素c弱阳性是什么意思hcv8jop1ns8r.cn 帕金森病是什么原因引起的cl108k.com 唐筛和无创有什么区别hcv7jop5ns1r.cn 英氏属于什么档次的jasonfriends.com
发痧是什么原因造成的hcv9jop6ns1r.cn 油条配什么好吃hcv8jop1ns2r.cn 新婚志喜是什么意思hcv9jop6ns6r.cn 6月24日什么星座onlinewuye.com 鸡是什么类hcv9jop6ns6r.cn
眼皮一直跳是什么原因hcv8jop4ns2r.cn 盆腔炎吃什么消炎药效果好helloaicloud.com 高的部首是什么hcv9jop7ns4r.cn 晨勃是什么意思啊hcv9jop7ns2r.cn karen是什么意思hcv7jop6ns9r.cn
百度