go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Examples
 
Subject: Examples
Author: EricJ
In response to: Java Annotation
Posted on: 11/30/2010 07:13:25 PM

  @Edible(true)  // Same as: @Edible(value = true)
  Item item = new Carrot();
 
  public @interface Edible {
    boolean value() default false;
  }
 


Another one:
  @Author(first = "FIRST", last = "LAST")
  Book book = new Book();
 
  public @interface Author {
    String first();
    String last();
  }


 

> On 11/30/2010 07:09:17 PM EricJ wrote:

An annotation, in the Java computer programming language, is a special form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and packages may be annotated. Unlike Javadoc tags, Java annotations can be reflective in that they can be embedded in class files generated by the compiler and may be retained by the Java VM to be made retrievable at run-time.

The Java platform has had various ad-hoc annotation mechanisms—for example, the transient modifier, or the @deprecated javadoc tag. The general purpose annotation (also known as metadata) facility was introduced to the Java Community Process as JSR-175 in 2002 and approved in September 2004. Annotations became available in the language itself beginning with version 1.5 of the JDK. A provisional interface for compile-time annotation processing was provided by the apt tool in JDK version 1.5, and was formalized through JSR-269 and integrated into the javac compiler in version 1.6





References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.