Reading and Writing Custom Annotation

Author posted by Jitendra on Posted on under category Categories JAVA and tagged as Tags with Leave a comment on Reading and Writing Custom Annotation

Article on Reading and Writing Custom Annotation with example

We have already discussed the basics of annotation and Meta Annotation in JAVA.  In this article i will explain how to read and write the custom annotation in JAVA.

To define custom Annotation, keyword interface is used preceded by @. Like interface, it also has the method declaration.
To make topic easy, lets I want to create the annotation CopyRight

package com.G2.Annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(value=RetentionPolicy.RUNTIME)
public @interface CopyRight {
	public String owner();
	public String location();
	public String year();
}

Continue reading “Reading and Writing Custom Annotation”

Meta Annotation – annotate other annotation

Author posted by Jitendra on Posted on under category Categories JAVA and tagged as Tags with 1 Comment on Meta Annotation – annotate other annotation

What is Meta Annotation and its usage in JAVA

In Previous article, we have seen that what are the types of annotation provided by the JAVA.

What is Meta Annotation ?

Fortunately Java allows us to define our own annotation. The annotations which are used to define costume annotations are known as “Meta Annotation“.

There are four annotation types in the “java.lang.annotation” package. These so-called meta-annotations are used to annotate other annotation types.

Inbuilt Annotation and Meta Annotations in JAVA
Inbuilt Annotation and Meta Annotations in JAVA

Continue reading “Meta Annotation – annotate other annotation”

Introduction to Annotation in JAVA

Author posted by Jitendra on Posted on under category Categories JAVA and tagged as Tags with 1 Comment on Introduction to Annotation in JAVA

Introduction to Annotation in JAVA

Annotation is the powerful feature provided by JAVA in version 5 (Tiger). It provides Data about the program to the compiler.
By Convention, Annotation comes first on its line.
Example:

/**
 *
 * @author jitendra Zaa
 * @version 1.0.5
 *
 */
public class TestAnnotations

Continue reading “Introduction to Annotation in JAVA”