不说废话,直接进入正题: java自定义注解主要有3步:1.编写@interface接口2.编写@interface对应的处理方法进行处理3.调用处理方法 示例一:判断奇偶:比如有一个字段no要判断奇偶,是偶数就抛出异常,有以下实体类: @Data public class Book { private int no; private String author; private String bookName; } 要判断 no是奇数还是偶数,首先写注解接口IsOdd:
2016.07.26 qq:992591601,欢迎交流 首先介绍些基本概念: Annotations(also known as metadata)provide a formalized way to add information to your code so that you can easily use that data at some later point. Annotations are partly motivated by a general trend toward c