Defining own annotation type - I

26 July 2008

The Java language supports defining new annotation types. An annotation type looks similar to an ordinary class, but it has some unique properties. One can use it with the at sign in the classes to annotate your other Java code.

Its right to say that defining a new annotation type is similar to creating an interface. We have to precede the interface keyword with the @ sign.

The following example shows the simplest possible annotation type:

package com.domain.tiger.a;
 
/**
 * Marker annotation to indicate that a method or class
 *   is still in progress.
 */
public @interface InProgress { }

Compile this annotation type and put it in your classpath. Now the annotation is ready to be used in the source code methods.

Continued …

del.icio.us:Defining own annotation type - I  digg:Defining own annotation type - I  spurl:Defining own annotation type - I  wists:Defining own annotation type - I  simpy:Defining own annotation type - I  newsvine:Defining own annotation type - I  blinklist:Defining own annotation type - I  furl:Defining own annotation type - I  reddit:Defining own annotation type - I  fark:Defining own annotation type - I  blogmarks:Defining own annotation type - I  Y!:Defining own annotation type - I  smarking:Defining own annotation type - I  magnolia:Defining own annotation type - I  segnalo:Defining own annotation type - I  gifttagging:Defining own annotation type - I

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Defining own annotation type - I

Leave a Reply