????RetentionPolicy ??????????????????????SOURCE??CLASS ??  RUNTIME ???????Java??????class?????????е??????
????????????????????????AnimTest ???????Retention???????????CLASS????????????????????????м???????????????????????????????????AnimTest?????????????????????????????????????????????????????????????????????
/**
* ??????????
* @author Administrator
*
*/
@Retention(value = RetentionPolicy.RUNTIME)     //???????????????????
public @interface AnimTest {
}
????????д?????????it  has  one
????3???????и???????????????÷?Χ???????????????????????
????????и?????Tagert???????Χ???Tagert ?????????????????????????????????????????????Tagert?????????????????κ????????????????????????????????????Χ
?????????AnimTest??????????????????????????Tagert
/**
* ??????????
* @author Administrator
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD})    //?????Χ???????????
public @interface AnimTest {
}
????????????????????????????????????????????????????????????????£?
public class ZhujieTest {
/**
* @param args
*/
@AnimTest  //???????????
public static void main(String[] args) {
boolean isAnim  = ZhujieTest.class.isAnnotationPresent(AnimTest.class);
if(isAnim)
System.out.println("it  has one");
else
System.out.println("no have");
}
}
???????????????????????????????? ?????????????? @Target(value = {ElementType.METHOD??ElementType.TYPE})??type????????
???????????????????????
????1?????????????????????????????????????????
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.itcast.classdemo.WeekDay;
/**
* ??????????
* @author Administrator
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD??ElementType.TYPE??ElementType.ANNOTATION_TYPE})
public @interface AnimTest {
String color();   //?????
int count();    //????
int[] arr();   //????
MetaAnnotation meta() default @MetaAnnotation("very food");  //???????
WeekDay day() default WeekDay.MON;   //???????
}
//?????
public @interface MetaAnnotation {
String value() default "heollo";    //??????
}
//?????
public enum WeekDay {
SUN??MON
}
????2???????????????????????
import com.itcast.zhujie.AnimTest;
@AnimTest (color ="red"??count =1??arr=234)   //????????????????????????
public class ZhujieTest {
/**
* @param args
*/
@AnimTest (color ="blue"??count=2??arr={3??21})
public static void main(String[] args) {
//?????AnimTest?????
boolean isAnim  = ZhujieTest.class.isAnnotationPresent(AnimTest.class);
if(isAnim){
//???AnimTest????????
AnimTest an = ZhujieTest.class.getAnnotation(AnimTest.class);
//?????????AnimTest?????????????
System.out.println(an.color());  // red
System.out.println(an.count());   //1
System.out.println(Arrays.toString(an.arr()));   //[234]
System.out.println(an.meta().value());   //very good
System.out.println(an.day());            //MON
System.out.println("it  has one");
}else
System.out.println("no have");
}
}
?????????????????
????1?????????????????String??int?????顢???????
????2???????????????????????????String color() default "red";
????3????????????????????????????????????????????????????                ?? @AnimTest (color ="blue"??count=2??arr={3??21})
????4?????????????????÷??似??AnimTest an = ZhujieTest.class.getAnnotation(AnimTest.class);
????5??????????????????????÷??????????????????
????6???????????????????????????????????value??????????????????????????磺@MetaAnnotation("very food")