@Retention(RetentionPolicy.RUNTIME) @interface Single{ intvalue(); } publicclassMain{ @Single(10) publicstaticvoidmyMethod()throws NoSuchMethodException { Main obj = new Main(); Method m = obj.getClass().getMethod("myMethod"); Single single = m.getAnnotation(Single.class); System.out.println(single.value()); }