Why does this code print 0?
@Table(name = "source")
public class SourceDetails implements DatabaseEntity{
public static void main(String[] args) {
System.out.println(SourceDetails.class.getAnnotations().length);
}
...
}
Why does this code print 0?
@Table(name = "source")
public class SourceDetails implements DatabaseEntity{
public static void main(String[] args) {
System.out.println(SourceDetails.class.getAnnotations().length);
}
...
}
Because you didn't set the retention of the annotation to runtime.
@Retention(RetentionPolicy.RUNTIME)
@interface Table{
String name();
int intValue();
}