The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
See Dev.java for updated tutorials taking advantage of the latest releases.
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.
With programmers worldwide writing classes and interfaces using the Java programming language, it is likely that many programmers will use the same name for different types. In fact, the previous example does just that: It defines a Rectangle
class when there is already a Rectangle
class in the java.awt
package. Still, the compiler allows both classes to have the same name if they are in different packages. The fully qualified name of each Rectangle
class includes the package name. That is, the fully qualified name of the Rectangle
class in the graphics
package is graphics.Rectangle
, and the fully qualified name of the Rectangle
class in the java.awt
package is java.awt.Rectangle
.
This works well unless two independent programmers use the same name for their packages. What prevents this problem? Convention.
Package names are written in all lower case to avoid conflict with the names of classes or interfaces.
Companies use their reversed Internet domain name to begin their package namesfor example, com.example.mypackage
for a package named mypackage
created by a programmer at example.com
.
Name collisions that occur within a single company need to be handled by convention within that company, perhaps by including the region or the project name after the company name (for example, com.example.region.mypackage
).
Packages in the Java language itself begin with java.
or javax.
In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore. For example:
Domain Name | Package Name Prefix |
---|---|
hyphenated-name.example.org |
org.example.hyphenated_name |
example.int |
int_.example |
123name.example.com |
com.example._123name |
柠檬什么时候成熟 | 中国的国花是什么 | 什么叫认知 | 风声鹤唳什么意思 | 嗓子干痒咳嗽吃什么药 |
肾结石可以喝什么饮料 | 预科班什么意思 | 工业氧气和医用氧气有什么区别 | 五月二十四号是什么星座 | 什么是指标生 |
马跟什么相冲 | 查黄体酮做什么检查 | 狗狗发烧吃什么药 | 什么样的电动牙刷好 | 什么咖啡最好 |
拉肚子吃点什么食物好 | 我国四大发明是什么 | 啄木鸟吃什么食物 | 胃火旺吃什么中成药 | 杯弓蛇影的寓意是什么 |
原点是什么hcv8jop8ns4r.cn | 坐西向东是什么宅hcv9jop1ns1r.cn | 飞机不能带什么东西hcv7jop5ns2r.cn | 黄粱是什么意思hcv9jop6ns0r.cn | 为什么老是做噩梦hcv9jop6ns8r.cn |
抽动症是什么原因造成的hcv8jop5ns4r.cn | 心绞痛吃什么药xjhesheng.com | 小病不治下一句是什么hcv7jop6ns2r.cn | 经常流鼻血是什么情况wuhaiwuya.com | 胎儿肾积水是什么原因引起的hcv8jop8ns7r.cn |
中水是什么意思hcv8jop6ns6r.cn | 刻意是什么意思hcv8jop6ns6r.cn | yellow是什么颜色chuanglingweilai.com | 氯化钙是什么hcv7jop7ns0r.cn | 梦见火烧房子是什么预兆hcv8jop6ns1r.cn |
笔名是什么意思baiqunet.com | 枸杞和红枣泡水喝有什么好处hcv9jop0ns0r.cn | 刘备和刘邦什么关系hcv7jop4ns7r.cn | 面色无华什么意思hcv8jop1ns7r.cn | 属马的人佩戴什么招财hcv7jop6ns7r.cn |