Java code
public class Demo
{
@W()
public void setMethod(){
}
}
最后,我新建一个类,用于输出该注解
Java code
public class RunTests
{
public static void main(String[] args) throws Exception
{
for (Method m : Class.forName("homework.Demo").getMethods())
{
if(m.isAnnotationPresent(W.class)){
System.out.println(m.getAnnotation(W.class));
System.out.println(m.getDefaultValue());
}
}
}
}