This example show you how to use the HelloAnnotation
annotation on the previous example code, How do I create a simple annotation?. We add the HelloAnnotation
annotation to our class and its methods.
package org.kodejava.lang.annotation;
@HelloAnnotation(value = "Good Morning", greetTo = "Universe")
public class HelloAnnotationExample {
public static void main(String[] args) {
HelloAnnotationExample hello = new HelloAnnotationExample();
hello.sayHi();
hello.sayHello();
}
@HelloAnnotation(value = "Hi there", greetTo = "Alice")
private void sayHi() {
}
@HelloAnnotation(value = "Hello there", greetTo = "Bob")
private void sayHello() {
}
}
Latest posts by Wayan (see all)
- How do I create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023