• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

What is Annotation interface

 
Ranch Hand
Posts: 594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please explain what is this interface "Annotation"?

Annotation

To create a custom annotation, the following syntax should be used



then what are the difference between Annotation Interface and "@interface"?
 
Marshal
Posts: 80943
521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read the documentation for that interface? Have you looked at the Jva® Languge Specification (=JLS) section mentioned there?
 
Bartender
Posts: 15743
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is a reflective language, meaning you can use some language features in code as if they're objects. An example of this is the Class class. Annotation is similar. All types that are declared using @interface will automatically also implement the Annotation interface. This interface is used in reflective code (such as annotation processors) to inspect code that was annotated some way.

For instance, if you have a class that contains a declaration like this:

You can write an annotation processor that looks like this:
 
reply
    Bookmark Topic Watch Topic
  • New Topic