posted 14 years ago
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