Hi ,

You can have a look more on : (Sun Tutorials)
http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html

Also good ones :
http://softwareas.com/java-annotations-tutorial-notes-benedict-heal-at-spa-2005


Thanks,
Ashok A V

On Thu, Aug 6, 2009 at 11:06 PM, Martin<[email protected]> wrote:
> Hi all there!
>
> I'm having problems to do the homework for annotations topic. Is that a new
> one? Because I can't find any help on this group..., and not much at other
> sites either...
>
> Well, the code I´m trying to run is this one:
>
> import java.lang.annotation.*;
>
> public class MyOwnAnnotationExample {
>
>     public MyOwnAnnotationExample() {
>    }
>
>     @RequestForEnhancement(id = 2868724,
>     synopsis = "Enable time-travel",
>     engineer = "Mr. Peabody",
>     date = "4/1/3007")
>     public String getSynopsis() {
>         return synopsis;
>     }
>
>     public void printAnnotations() {
>         Class c = this.getClass();
>         Annotation[] annotations = c.getAnnotations();
>         int numberOfAnnotations = annotations.length;
>         System.out.println("Class " + c.getName() + " has " +
>                 numberOfAnnotations + " annotations");
>
>         for (int i = 0 ; i < numberOfAnnotations; i++) {
>             System.out.println("Annotation " + i + ": " + annotations[i] +
>                     ", type" + annotations[i].annotationType().getName());
>         }
>     }
>
>     public static void main(String[] args) {
>         MyOwnAnnotationExample moae = new MyOwnAnnotationExample();
>         moae.printAnnotations();
>     }
>
> }
>
> And the output:
>
> run:
> Class MyOwnAnnotationExample has 0 annotations
> BUILD SUCCESSFUL (total time: 1 second)
>
> I guess the first problem is that in printAnnotations I´m trying to work
> with class while I'm annotating a method, but I don't get to know how to
> access the annotation of the getSynopsis() method.
>
> Can anyone give me any tips?
>
> Thanks a lot,
>
> Martin.
>
>
>
> >
>



-- 
Victory belongs to the most persevering.
 - Napoleon

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to