How do I annotate a class or method?
Category: java.lang.annotation, viewed: 2839 time(s).
This example show you how to use the HelloAnno annotation on
the previous example code, How do I create a simple annotation?. We add the HelloAnno annotation to our class and its methods.
package org.kodejava.example.annotation;
@HelloAnno(value = "Good Morning", greetTo = "Universe")
public class HelloAnnoExample {
public static void main(String[] args) {
HelloAnnoExample example = new HelloAnnoExample();
example.sayHi();
example.sayHello();
}
@HelloAnno(value = "Hi there", greetTo = "Alice")
public void sayHi() {
}
@HelloAnno(value = "Hello there", greetTo = "Bob")
public void sayHello() {
}
}
More examples on java.lang.annotation