假设有一个@YourAnnotation注解。在一个方法上放置两次:
@YourAnnotation
@YourAnnotation
public void test(){
//TODO
}
会看到IDE报错:
Duplicate annotation @YourAnnotation. Repeated annotations are allowed only at source level 1.8 or above
当然,即使是使用Java8按1.8编译也会报错:
Duplicate annotation of non-repeatable type @YourAnnotation. Only annotation types marked @Repeatable can be used multiple times at one target.
但是,后面一句告诉我们,有解决的办法,这也说明Java8支持重复注解。来看具体怎么做:
先写一个...... 【阅读全文】
SEO:多注解,multiple annotations,多次注解,多次使用注解,同一位置多次使用注解,方法上多个同一注解,方法上多个注解报错,
最后
以上就是小巧超短裙最近收集整理的关于Java8多重注解示例的全部内容,更多相关Java8多重注解示例内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复