View RSS Feed

Java Object

Annotations

Rate this Entry
by , 04-26-2012 at 06:26 PM (815 Views)
Annotations provide that data regarding program which is not program’s part. No direct effect they have at the code operation, they annotate.

Uses of the annotations are as following:

  • Information for compiler: Annotations can be used by the compiler for detection of the errors or suppress warning.
  • Deployment and compiler-time processing: Software tools can process the annotation information so that to generate the code, XML files or so forth.
  • Runtime processing: At runtime few annotations present are being examined.


To field’s declaration, methods, classes or program elements, the annotations might be applicable.
Annotations usually come first conventionally on its lines & may include elements that consist of un-named & named values:
Java Code:
@Author(
   name = "Benjamin Franklin",
   date = "3/27/2003"
)
class MyClass() { }
or
@SuppressWarnings(value = "unchecked")
void myMethod() { }
One element known as value may go through the name omission:
@SuppressWarnings("unchecked")
void myMethod() { }
If elements are not present in annotation then parenthese omission might take place, as in:
@Override
void mySuperMethod() { }

Submit "Annotations" to Facebook Submit "Annotations" to Digg Submit "Annotations" to del.icio.us Submit "Annotations" to StumbleUpon Submit "Annotations" to Google

Tags: annotations Add / Edit Tags
Categories
Tutorial

Comments