Defining your own Annotations

You can use the @Interface annotation to create your own annotation definition.

To define your own annotations:

Use the @Interface annotation to define your own annotation definition:

public @interface CreatedBy{
     String name();
     String date();
     boolean contractor() default false;
}          

@CreatedBy(name = "Mary Smith",date="02/02/2008");
public class MyClass{....}         

Meta-annotations: Meta-annotations (annotations of annotations) provide additional information on how an annotation should be used:

Other built-in annotations:

 

Related concepts

Creating and configuring Java EE modules using annotations

Scope and placement of annotations

Using the Annotations view

 

Related tasks

Adding annotations

Editing annotations

Removing annotations

Overridden annotations