Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Annotations  RSS feed

 
Amit Sethi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are annotations ? Why they are used ?...
I have gone through java doc & tutorial but it is not clear yet. can any body pls explain me in detail or a tutorial's link ?

Regards
Amit Sethi
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's meta-data, or data about the class. It's like a post-it note you can stick on the class. Later others can check to see if they are there and read what they say.

At one level it's a nice replacement for "marker interfaces" like Serializable. We can test to see if a class has an annotation instead of whether it implements an interface.

At another level, annotations can hold important information that tells a development tool how to generate code, or a runtime framework how to handle an object.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit,
Annotations are a way of specifying metadata information about the code. I assume you've seen Sun's tutorial? JavaWorld's article is a bit easier to read.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!