• 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

about java annonation. How it is effective on java coding?

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I want to konw about java annonation feature. How it is effective on java coding and java web application development. please give me some example so that i can clearly understand java annonation.

thanking you
codeperl
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Not exactly sure what you mean by "effective". An annotation is merely a way to attach some sort of data to java, sort of like making little notes in the margin of a book, which is where the term annotation comes from.

You define a datastructure, similar to defining an interface. And then you declare (attach) these annotations anywhere you are able to use a java modifier -- a class, a method, or a class or instance variable.


Another java component, can then use reflection to get and use these little notes. For example, the compiler uses annotations to get hints from the programmer on what to do with certain warning conditions. Hibernate uses annotation to get information on how to map a class to a database table (the previous technique of using an XML file, which is harder to keep in sync with the java class, is now optional). Etc.

I don't know how any of these examples can be considered "effective" though.

Henry


 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See Sun's Java Tutorial on annotations to learn about annotations in detail. The starting page gives some reasons why annotations are useful:

Annotations have a number of uses, among them:

  • Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings.
  • Compiler-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth.
  • Runtime processing — Some annotations are available to be examined at runtime.
  •  
    reply
      Bookmark Topic Watch Topic
    • New Topic