日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

java info是什么_什么是package-info.java

發(fā)布時(shí)間:2023/12/14 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java info是什么_什么是package-info.java 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在java項(xiàng)目中創(chuàng)建package以后,可以在package下放一個(gè)package-info.java文件。

這個(gè)文件有什么作用?如何生成?

三個(gè)作用:

為標(biāo)注在包上Annotation提供便利;

聲明友好類和包常量;

比如一個(gè)包中有很多的內(nèi)部訪問(wèn)的類或常量,就可以統(tǒng)一的放到package-info類中,這樣就方便,而且集中管理,減少friendly類到處游走的情況,看例子:

//這里是包類,聲明一個(gè)包使用的公共類,強(qiáng)調(diào)的是包訪問(wèn)權(quán)限

class PkgClass{

public void test(){

}

}

//包常量,只運(yùn)行包內(nèi)訪問(wèn),適用于分“包”開(kāi)發(fā)

class PkgConst{

static final String PACAKGE_CONST="ABC";

}

提供包的整體注釋說(shuō)明。

Package Documentation Prior to Java 5, package level documentation (the documentation shown in Javadocs for a package) was placed in package.html. Today, the description and other related documentation for a package can be written up in the package-info.java file and it gets used in the production of the Javadocs. As a demonstration, the example package-info.java…

/**

* Domain classes used to produce the JSON and XML output for the RESTful services.

*

* These classes contain the JAXB annotations.

*

* @since 1.0

* @author jwhite

* @version 1.1

*/

package com.intertech.cms.domain;

… results in the following Javadocs.

package-info.java’s purpose The package-info.java is a Java file that can be added to any Java source package. Its purpose is to provide a home for package level documentation and package level annotations. Simply create the package-info.java file and add the package declaration that it relates to in the file. In fact, the only thing the package-info.java file must contain is the package declaration.

如何創(chuàng)建:

參考

總結(jié)

以上是生活随笔為你收集整理的java info是什么_什么是package-info.java的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。