Jump to content

How to get annotation attribute value from the main method


Recommended Posts



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");


@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD })
public @interface storyInfo {

    String ID();


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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...