Java - Annotating Java Package

Introduction

Create a file named package-info.java, and place the annotated package declaration in it.

The following code shows the contents of the package-info.java file.

When you compile the package-info.java file, a class file will be created.

// package-info.java
@Version(major=1, minor=0)
package com.book2s.annotation;

You can have contents like the following in a package-info.java file:

// package-info.java
@com.book2s.myannotations.Author("book2s.com")
@Reviewer("abc")
package com.book2s.annotation;

import com.book2s.myannotations.Reviewer;

The import statement is used to import annotation type.