JAVA小结

interface定义接口

@interface定义annotation注解

都没有函数体。

使用方法:

implement接口名

@注解名---定义文件中有属性添属性(对应属性)

使用注解必然用到元注解@Target,@Retention,@Documented,@Inherited,元注解负责注解其他注解

@Target说明修饰对象{

ElementType.TYPE:Class, interface or enum declaration.

ElementType.FIELD:Field declaration.

ElementType.METHOD:Method declaration.

ElementType.PARAMETER:Parameter declaration.

ElementType.CONSTRUCTOR:Constructor declaration.

ElementType.LOCAL_VARIABLE:Local variable declaration.

ElementType.ANNOTATION_TYPE:Annotation type declaration.

ElementType.PACKAGE:Package declaration.

}

@Target的属性是一个数组类型,所以可以有多个值格式为{1,2,3}

@Retention定义注解被保留的时间{

RetentionPolicy.SOURCE:Annotation is only available in the source code.

RetentionPolicy.CLASS:Annotation is available in the source code and in the class file, but not at runtime. This is the default policy.

RetentionPolicy.RUNTIME:Annotation is available in the source code, the class file and is available at runtime.

}

@Documented标注为API,可以被javadoc类似工具文档化,标记注解没有成员

@Inherited标记的注解class的子类将继承为annotation。

注解参数支持的参数成员数据类型:

1:所有基本类型:int,float,long,char,byte,short,double,boolean

2:String,Class,enum,Annotation

3:以上类型对应数组

类型修饰符:只能使用public或default



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值