Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are Annotations ? Why do wee need them ?

 
shukla raghav
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i stumbled upon annotations while trying to integrate GWT with Struts 2. i was looking for a GWT/Struts 2 plugin. with a great difficulty finally i found the plugin at the following URL

URL :

If you look at the webpage, the author of the plugin says

This plugin allow you to write Ext.Direct Action using annotation:
@ExtDirectAction
@ExtDirectMethod


i have never used annotation so i dont know what are they for and what it means here to use the above mentioned annotations. Please tell me in detail.

thanks in advance

 
Manish Singh
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
annotations are like metadata for the functions and variables.
I will suggest you to read some small book or documentation about it
 
Ravi Choudhary
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To Know more about the annotations check out this link:webpage
 
Campbell Ritchie
Sheriff
Pie
Posts: 48976
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravikumar Choudhary wrote:To Know more about the annotations check out this link:webpage
Also find the most recent edition of Thinking in Java by Bruce Eckel. Don't look in the 3rd edition or earlier.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
probably this and this link help you
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good example of a common annotation would be the "@Override" annotation. You can add this annotation to methods that you've overridden. The compiler will throw an error if the method actually doesn't override anything. This is great because if you accidentally misspell the name of a method you want to override, it will point it out for you.



Annotations were added in Java 1.5.
 
shukla raghav
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i have generally seen in the IDE's that attach a marked warning, the warning can be replaced by putting an annotation. I would certainly go through the linked resources provided in this section and i hope it resolves my problem.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48976
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be careful about replacing warnings by annotations; the @SuppressWarnings annotation might allow you to bypass the type checking in generics and suffer a ClassCastException later on. Adding the @Override annotation to all overridden methods is a good idea.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic