标签:3.0 test single marker hello 学习 double ann war
Java提供了特定的注解(比较基础的例如:Override、Deprecated、SuppressWarnings)。
自定义注解:
有三种:
普通注解:
public @interface aAnnotation {
String value();
int i();
float f() default 2.0f;
double d();
}
public class AnnotationTester {
@aAnnotation(value = "hello", i = 1, f = 2.0f, d = 3.0)
public void Method()
{
}
}
标记注解:
public @interface MarkerAnnotation {
}
public class AnnotationTester {
@MarkerAnnotation
public void Method()
{
}
}
单值注解:
public @interface SingleValueAnnotation {
String value();
}
public class AnnotationTester {
@SingleValueAnnotation("hello")
public void Method()
{
}
}
标签:3.0 test single marker hello 学习 double ann war
原文地址:http://www.cnblogs.com/quanxi/p/7082530.html