import java.lang.annotation.*;
import java.lang.reflect.*;

// from Java, The Complete Reference, 9th Edition

@Retention(RetentionPolicy.RUNTIME)
@interface MyAnno {
    String str();
    int val();
}

class Test {
    @MyAnno(str="annotation example", val=100)
    public void foo() {
        System.out.println("bar");
    }
}

class Main {
    public static void main(String[] args) throws NoSuchMethodException {
        Class<?> c = Test.class;
        Method m = c.getMethod("foo");
        MyAnno anno = m.getAnnotation(MyAnno.class);
        System.out.println(anno.str() + " " + anno.val());
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: