3
如何在main
中訪問中的Sample
類是true還是false?
我應該在主課上寫什麼?運行時訪問註釋
package annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface annotation {
public String name() default "Jimmy";
public boolean check() default false;
}
package annotation;
@annotation(name = "Jack", check = false)
public class Sample {
public String str = "Hi";
public void printHi(String str) {
System.out.println(str);
}
}
package annotation;
public class Main {
public static void main(String[] args) {
}
}