OK FORGET Fırst one please
this is the situation that i am in.

output:
Class MyOwnAnnotationProject has 1 declaredAnnotations
Annotation 0: @RequestForEnhancement(engineer=Ms. Eagle,
date=03/03/2009, id=55, synopsis=sum), typeRequestForEnhancement
Class MyOwnAnnotationProject has 0 declaredAnnotations
Class MyOwnAnnotationProject has 0 declaredAnnotations

is it ok?
______________________________________________________________________________________________________
import java.lang.annotation.*;
import java.lang.reflect.*;

public class MyOwnAnnotationProject {


    public MyOwnAnnotationProject() {

    }
 @RequestForEnhancement(id = 55,
    synopsis = "sum",
    engineer = "Ms. Eagle",
    date = "03/03/2009")




    public void printAnnotations() {
        Class c = this.getClass();
        Method[] m = c.getDeclaredMethods();
        for (int i = 0; i<m.length; i++){
            Annotation[] declaredAnnotations = m
[i].getDeclaredAnnotations();
int numberDeclaredAnnotations = declaredAnnotations.length;
System.out.println("Class " + c.getName() + " has " +
       numberDeclaredAnnotations + " declaredAnnotations");
for (int j = 0 ; j < numberDeclaredAnnotations; j++) {
       System.out.println("Annotation " + j + ": "+
       declaredAnnotations[j] +  ", type" + declaredAnnotations
[j].annotationType().getName().toString());
}

                }
}
    public static void main(String[] args) {
        MyOwnAnnotationProject ar = new MyOwnAnnotationProject();
        ar.printAnnotations();

       }
    public void addition(){
       int i = 2;
       int j = 1;
       int result=i+j;
    }
}

On Nov 17, 10:01 pm, papatya <[email protected]> wrote:
> ı read the forum but i mixed evrythg
> i can't find the right output
> hope you to help me
>
> run:
> Class MyOwnAnnotationProject has 0 declaredAnnotations
> BUILD SUCCESSFUL (total time: 0 seconds)
>
> What is wrong with this?
> ______________________________________________________________
> import java.lang.annotation.Annotation;
> import java.lang.reflect.Method;
>
> /**
>  *
>  * @author ppty
>  */
> import java.lang.annotation.*;
> import java.lang.reflect.*;
> public class RunTimeAnnotation {
>     MyOwnAnnotationProject ac;
>     public RunTimeAnnotation() {
>         ac = new MyOwnAnnotationProject ();
>     }
>     public void printAnnotations() {
>         Class c = ac.getClass();
>         Method[] m = c.getDeclaredMethods();
>
>         for (int i = 0; i<m.length; i++){
>           Annotation[] declaredAnnotations = m
> [i].getDeclaredAnnotations();
> int numberDeclaredAnnotations = declaredAnnotations.length;
> System.out.println("Class " + c.getName() + " has " +
>        numberDeclaredAnnotations + " declaredAnnotations");
> for (int j = 0 ; j < numberDeclaredAnnotations; j++) {
>        System.out.println("Annotation " + j + ": "+
>        declaredAnnotations[j] +  ", type" + declaredAnnotations
> [j].annotationType().getName().toString());}
>                 }
> }
>
>     public static void main(String[] args) {
>         RunTimeAnnotation ar = new RunTimeAnnotation();
>         ar.printAnnotations();
>        }
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

-- 
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