The following code contains the code for an annotation type called Name with two elements of the String type.
@interface Name {
String first();
String last();
}
@Name(first="Tom", last="James") class NameTest { @Name(first="Mary", last="Edith") public void aMethod() { } }
You can use the string concatenation operator (+) in the value expression for an element of a String type.
@Name(first="A" + "B", last="C" + "D")
@interface Name { String first(); //from w w w. j a v a2 s. c o m String last(); } @Name(first="A" + "B", last="C" + "D") class A{ }