The concept notes and annotations common
I. Introduction
Annotations can simplify the development process in a complex configuration file, optimized model of the structure, so that the current becomes gradually development model annotation + + reflective design pattern
Second, the concept notes
Annotation concept
* Notes in the code symbol is a mark, these marks may be symbols of the source code, compile and runtime are read, performing the corresponding functions.
Annation modification range
* Annotations can be used to modify the code of the package, class, method, constructor, variables and parameters, which information is stored in the Annation (Key: Val) key-value pair.
Third, the common comment
@Override: override the parent class method @Deprecated: the current code is outdated, but you can continue to use. @Test: The current approach to testing methods
@Override use annotations
public class AnnotationTest {
/**
* @Override 重写父类方法
*/
private String name;
private int age;
@Override
public String toString() {
return "AnnotationTest{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
NOTE Using @Deprecated
//Date类中的过时方法
@Deprecated
public Date(String s) {
this(parse(s));
}
NOTE Using @Test
@Test
public void test() {
System.out.println("Test Function");
}