newcoder1010 Posted March 10, 2022 Share Posted March 10, 2022 Hello, Test public class AnnotationTest extends Base{ @storyInfo(ID = "Story 1") public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("First annotation ever"); } } Code @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) public @interface storyInfo { String ID(); } Base public class Base { // How to read the value of ID attribute everytime I run main } Every time I run main method, how can retrieve the value of ID in Base? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now