Сначала создайте пользовательскую аннотацию
@Retention(RetentionPolicy.RUNTIME)
@interface Annotation {
public int value1();
public int value2();
}
Затем используйте ее
public class TestClass {
@Annotation(value1 = 15, value2 = 30)
public static void test(){
Class cl = TestClass.class;
Method[] allMethods = cl.getMethods();
Method thisMethod = null;
for (Method m : allMethods)
if (m.getName().equals("test")) thisMethod = m;
Annotation a = thisMethod.getAnnotation(Annotation.class);
a.value1(); //returns 15
a.value2(); //returns 30
}
}