ı 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();
}
}
--
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