JAVA annotationÈëÃÅ
JAVA annotationÈëÃÅ
×î½ü¶ÔspringÔ´Âë¸ÐÐËȤ£¬½ñÌì¿´µ½annotation²¿·Ö£¬ÂÔ¼ÇÖ®¡£
Ò». ×î³£¼ûµÄannotation
@Override:ÓÃÔÚ·½·¨Ö®ÉÏ£¬ÓÃÀ´¸æËß±ðÈËÕâÒ»¸ö·½·¨ÊǸÄд¸¸ÀàµÄ
@Deprecated:½¨Òé±ðÈ˲»ÒªÊ¹ÓþɵÄAPIµÄʱºòÓõÄ,±àÒëµÄʱºò»áÓòúÉú¾¯¸æÐÅÏ¢,¿ÉÒÔÉ趨ÔÚ³ÌÐòÀïµÄËùÓеÄÔªËØÉÏ.
@SuppressWarnings:ÔÝʱ°ÑһЩ¾¯¸æÐÅÏ¢ÏûÏ¢¹Ø±Õ
@Entity:±íʾ¸ÃÀàÊǿɳ־û¯µÄÀà
¶þ. Éè¼ÆÒ»¸ö×Ô¼ºµÄAnnotation
ÏÈ¿´´úÂëÔÙ½²»°
1. Ö»ÓÐÒ»¸ö²ÎÊýµÄAnnotationʵÏÖ
package chb.test.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation1 {
String value();
}
2. ÓÐÁ½¸ö²ÎÊýµÄAnnotationʵÏÖ
package chb.test.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation2 {
String description();
boolean isAnnotation();
}
3. AnnotationʵÑéÀà
package chb.test.annotation;
@MyAnnotation1("this is annotation1")
public class AnnotationDemo {
@MyAnnotation2(description="this is annotation2",isAnnotation=true)
public void sayHello(){
System.out.println("hello world!");
}
}
4.Annotation²âÊÔ˵Ã÷Àà
package chb.test.annotation;
import java.lang.reflect.Method;
import org.junit.Test;
public class TestAnnotation {
@Test
public void test() throws ClassNotFoundException, SecurityException, NoSuchMethodException{
Clas
Ïà¹ØÎĵµ£º
һЩ³õѧJAVAµÄÅóÓÑ¿ÉÄÜ»áÓöµ½JAVAµÄÊý¾ÝÀàÐÍÖ®¼äת»»µÄ¿àÄÕ£¬ÀýÈ磬ÕûÊýºÍfloat,doubleÐÍÖ®¼äµÄת»»£¬ÕûÊýºÍStringÀàÐÍÖ®¼äµÄת»»£¬ÒÔ¼°´¦Àí¡¢ÏÔʾʱ¼ä·½ÃæµÄÎÊÌâµÈ¡£ÏÂÃæ±ÊÕ߾Ϳª·¢ÖеÄһЩÌå»á½éÉܸø´ó¼Ò¡£
ÎÒÃÇÖªµÀ£¬JavaµÄÊý¾ÝÀàÐÍ·ÖΪÈý´óÀ࣬¼´²¼¶ûÐÍ¡¢×Ö·ûÐͺÍÊýÖµÐÍ£¬¶øÆäÖÐÊýÖµÐÍÓÖ·ÖΪÕûÐͺ͸¡µãÐÍ£»Ïà¶Ô ......
ż¶ûÔÚÍøÉÏ·¢ÏÖµÄһƬ¹ØÓÚÕÆÎÕJAVAµÄ±ê×¼£¬¸Ð¾õÓеãÒâ˼£¬ËäÈ»ÔÚһЩ¹ÛµãÉÏÓÐЩƫÆÄ£¬µ«×÷ΪѧϰJAVAµÄÒýµ¼Éпɡ£ÖÁÓÚÔ´´ÊÇËûÓбØÒª¿¼Ö¤¡£
ʱ³£¿´µ½Ò»Ð©ÈË˵ÕÆÎÕÁËJava£¬µ«ÊÇÈÃËûÃÇÓÃJava×öÒ»¸öʵ¼ÊµÄÏîÄ¿¿ÉÄÜÓÖÀ§ÄÑÖØÖØ£¬ÔÚÕâÀ±ÊÕ߸ù¾Ý×Ô¼ºµÄÒ»µãÀí½â¶·µ¨Ìá³ö×Ô¼ºµÄһЩ¶ÔÕÆÎÕJavaÕâ¸ö˵·¨µÄ±ê×¼£¬µ±È»¶ÔÓÚР......
1.JavaÔÚÐéÄâ»úÉÏÔËÐÐ
JavaÔ´´úÂë²¢²»ÊDZ»±àÒë³ÉΪÆÕͨµÄ»úÆ÷´úÂë¡£¶øÊDZ»·Òë³ÉΪÐéÄâ»ú¿ÉÒÔÖ´ÐеĴúÂë¡£Ò»¸öJava½âÊÍÆ÷×îÖÕÖ´ÐÐÕâЩ´úÂë¡£ÕâÆäÖÐûÓÐÁ¬½ÓµÄ¹ý³Ì£»½âÊÍÔÚÐèÒªµÄʱºò¶¯Ì¬µÄ¼ÓÔØһЩÀࣻ
2.JavaÊÇÍêÈ«ÃæÏò¶ÔÏóµÄ
JavaÊÇÒ»ÖÖÍêÈ«ÃæÏò¶ÔÏóµÄÓïÑÔ¡£ÕâÒâζ×ÅÄã¶ÔÈκÎÒ»¸öJava¶ÔÏóËù×öµÄ¶¯×÷¶¼ÊÇͨ¹ýÒ ......
¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆΪһ¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£ Ïß³ÌÓÖ³ÆΪÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖеÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄͨÐÅÔ¶½Ï½ø³Ì¼òµ¥¡£
Ò»£ºÀí½â¶àÏß³Ì
& ......
Ò»¡¢ µ¥ÏîÑ¡ÔñÌâ
¡¡¡¡1£®JavaÊÇ´Ó£¨ £©ÓïÑԸĽøÖØÐÂÉè¼Æ¡£
¡¡¡¡A£®Ada B£®C++ C£®Pasacal D£®BASIC
¡¡¡¡´ð°¸£ºB
¡¡¡¡
¡¡¡¡2£®ÏÂÁÐÓï¾äÄÄÒ»¸öÕýÈ·£¨ £©
¡¡¡¡A£® Java³ÌÐò¾±àÒëºó»á²úÉúmachine code
¡¡¡¡B£® Java³ÌÐò¾±àÒëºó»á²úÉúbyte code
¡¡¡¡C£® Java³ÌÐò¾±àÒëºó»á²úÉúDLL
¡¡¡¡D£® ÒÔÉ϶¼²»ÕýÈ·
¡¡¡¡´ð°¸£ºB ......