Annotation

  1. Annotation類的定義方式:public @interface MyAnnotation {
  2. retention 分:SOURCE,CLASS,RUNTIME
  3. annotation type分:TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE,ANNOTATION_TYPE,PACKAGE
  • annotation type:type

  type是加在類上面的註釋:spa

     用的時候,直接在class上面註釋就好了:註釋是以annotation對象的形式存在的3d

 

獲取註釋對應屬性值的方法:對象

ans的長度是2blog

  •  獲取註釋屬性值

不用new bird  這樣就能夠了:MyAnnotation bb=Bird.class.getAnnotation(MyAnnotation.class);:get

  • 獲取屬性值方法二

  • 若是是annotation type 是method ,那麼獲取有註解的方法:

 

七月又過了三分之二臥槽,睡覺了io

相關文章
相關標籤/搜索