日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2023/12/14 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java info是什么_什么是package-info.java 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在java項目中創建package以后,可以在package下放一個package-info.java文件。

這個文件有什么作用?如何生成?

三個作用:

為標注在包上Annotation提供便利;

聲明友好類和包常量;

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

//這里是包類,聲明一個包使用的公共類,強調的是包訪問權限

class PkgClass{

public void test(){

}

}

//包常量,只運行包內訪問,適用于分“包”開發

class PkgConst{

static final String PACAKGE_CONST="ABC";

}

提供包的整體注釋說明。

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.

如何創建:

參考

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。