Java examples for Reflection:Annotation
print Annotations via Reflection
//package com.java2s; import java.lang.annotation.Annotation; import static java.lang.System.out; public class Main { public static void printAnnotations(Class<?> c) { Annotation[] annotations = c.getAnnotations(); out.format("Annotation => %n"); if (annotations.length == 0) { out.format(" --%s", "No declared annotation found"); } else {// w ww.j ava 2 s . co m for (Annotation a : annotations) { out.format("--%s", a.getClass().getCanonicalName()); } } out.format("%n%n"); } }