在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java/ Java: 如何理解 <A extends Annotation>模

Java: 如何理解 <A extends Annotation>模板?

如下方法可以得到注解

public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return (A) annotationData().annotations.get(annotationClass);
}

但是注解定義一般不寫extends Annotation
是所有的注解都默認(rèn)是extends Annotation的嗎?

回答
編輯回答
風(fēng)清揚
注解本質(zhì)上就是一個接口,它的實質(zhì)定義為: interface SomeAnnotation extends Annotation。
這個 Annotation 接口位于 java/lang/annotation 包,它的注釋中第一句話就是 The common interface extended by all annotation types.
-- 通過反射,動態(tài)修改注解的某個屬性值
2017年11月4日 23:08
編輯回答
失魂人

建議查Annotation源碼,這樣你想要的都有了

2017年9月14日 15:10