笔记摘自 廖雪峰的官方网站-Java教程-注解 。
使用注解
注解(Annotation)是放在Java源码的类、方法、字段、参数前的一种特殊“注释”。
// this is a component:
@Resource("hello")
public class Hello {
@Inject
int n;
@PostConstruct
public void hello(@Param String name) {
System.out.println(name);
}
@Override
public String toString() {
return