• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What are Annotations ? Why do wee need them ?

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To Know more about the annotations check out this link:webpage
 
Marshal
Posts: 79040
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
probably this and this link help you
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79040
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic