当前位置: 首页 > news >正文

上海市奉贤区建设局网站关键词优化排名软件怎么样

上海市奉贤区建设局网站,关键词优化排名软件怎么样,深圳做步步高的公司网站,behance官网网址3.注解 3.1概述【理解】 概述 对我们的程序进行标注和解释 注解和注释的区别 注释: 给程序员看的注解: 给编译器看的 使用注解进行配置配置的优势 代码更加简洁,方便 3.2自定义注解【理解】 格式 public interface 注解名称 { ​ public 属性类型 属性名() default 默认值…

3.注解

3.1概述【理解】

  • 概述

    对我们的程序进行标注和解释

  • 注解和注释的区别

    • 注释: 给程序员看的
    • 注解: 给编译器看的
  • 使用注解进行配置配置的优势

    代码更加简洁,方便

3.2自定义注解【理解】

  • 格式

    public @interface 注解名称 {

    ​ public 属性类型 属性名() default 默认值 ;

    }

  • 属性类型

    • 基本数据类型
    • String
    • Class
    • 注解
    • 枚举
    • 以上类型的一维数组
  • 代码演示

    public @interface Anno2 {
    }public enum Season {SPRING,SUMMER,AUTUMN,WINTER;
    }public @interface Anno1 {//定义一个基本类型的属性int a () default 23;//定义一个String类型的属性public String name() default "itheima";//定义一个Class类型的属性public Class clazz() default Anno2.class;//定义一个注解类型的属性public Anno2 anno() default @Anno2;//定义一个枚举类型的属性public Season season() default Season.SPRING;//以上类型的一维数组//int数组public int[] arr() default {1,2,3,4,5};//枚举数组public Season[] seasons() default {Season.SPRING,Season.SUMMER};//value。后期我们在使用注解的时候,如果我们只需要给注解的value属性赋值。//那么value就可以省略public String value();}//在使用注解的时候如果注解里面的属性没有指定默认值。
    //那么我们就需要手动给出注解属性的设置值。
    //@Anno1(name = "itheima")
    @Anno1("abc")
    public class AnnoDemo {
    }
    
  • 注意

    如果只有一个属性需要赋值,并且属性的名称是value,则value可以省略,直接定义值即可

  • 自定义注解案例

    • 需求

      自定义一个注解@Test,用于指定类的方法上,如果某一个类的方法上使用了该注解,就执行该方法

    • 实现步骤

      1. 自定义一个注解Test,并在类中的某几个方法上加上注解
      2. 在测试类中,获取注解所在的类的Class对象
      3. 获取类中所有的方法对象
      4. 遍历每一个方法对象,判断是否有对应的注解
    • 代码实现

      //表示Test这个注解的存活时间
      @Retention(value = RetentionPolicy.RUNTIME)
      public @interface Test {
      }public class UseTest {//没有使用Test注解public void show(){System.out.println("UseTest....show....");}//使用Test注解@Testpublic void method(){System.out.println("UseTest....method....");}//没有使用Test注解@Testpublic void function(){System.out.println("UseTest....function....");}
      }public class AnnoDemo {public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {//1.通过反射获取UseTest类的字节码文件对象Class clazz = Class.forName("com.itheima.myanno3.UseTest");//创建对象UseTest useTest = (UseTest) clazz.newInstance();//2.通过反射获取这个类里面所有的方法对象Method[] methods = clazz.getDeclaredMethods();//3.遍历数组,得到每一个方法对象for (Method method : methods) {//method依次表示每一个方法对象。//isAnnotationPresent(Class<? extends Annotation> annotationClass)//判断当前方法上是否有指定的注解。//参数:注解的字节码文件对象//返回值:布尔结果。  true 存在  false 不存在if(method.isAnnotationPresent(Test.class)){method.invoke(useTest);}}}
      }
      

3.3元注解【理解】

  • 概述

    元注解就是描述注解的注解

  • 元注解介绍

    元注解名说明
    @Target指定了注解能在哪里使用
    @Retention可以理解为保留时间(生命周期)
    @Inherited表示修饰的自定义注解可以被子类继承
    @Documented表示该自定义注解,会出现在API文档里面。
  • 示例代码

    @Target({ElementType.FIELD,ElementType.TYPE,ElementType.METHOD})  //指定注解使用的位置(成员变量,类,方法)
    @Retention(RetentionPolicy.RUNTIME) //指定该注解的存活时间
    //@Inherited //指定该注解可以被继承
    public @interface Anno {
    }@Anno
    public class Person {
    }public class Student extends Person {public void show(){System.out.println("student.......show..........");}
    }public class StudentDemo {public static void main(String[] args) throws ClassNotFoundException {//获取到Student类的字节码文件对象Class clazz = Class.forName("com.itheima.myanno4.Student");//获取注解。boolean result = clazz.isAnnotationPresent(Anno.class);System.out.println(result);}
    }

文章转载自:
http://suppurant.Lgnz.cn
http://pullman.Lgnz.cn
http://comstockian.Lgnz.cn
http://ann.Lgnz.cn
http://cascarilla.Lgnz.cn
http://scalding.Lgnz.cn
http://runcinate.Lgnz.cn
http://tatar.Lgnz.cn
http://ietf.Lgnz.cn
http://confined.Lgnz.cn
http://hidrotic.Lgnz.cn
http://effractor.Lgnz.cn
http://maladministration.Lgnz.cn
http://arca.Lgnz.cn
http://cynghanedd.Lgnz.cn
http://viscerate.Lgnz.cn
http://pecuniarily.Lgnz.cn
http://tagboard.Lgnz.cn
http://isodynamic.Lgnz.cn
http://electrical.Lgnz.cn
http://thule.Lgnz.cn
http://yiddish.Lgnz.cn
http://sulphanilamide.Lgnz.cn
http://osfcw.Lgnz.cn
http://cyclandelate.Lgnz.cn
http://perinatal.Lgnz.cn
http://canadien.Lgnz.cn
http://morningtide.Lgnz.cn
http://obelus.Lgnz.cn
http://wearing.Lgnz.cn
http://miscalculate.Lgnz.cn
http://choregus.Lgnz.cn
http://coastal.Lgnz.cn
http://syringeal.Lgnz.cn
http://probationership.Lgnz.cn
http://handed.Lgnz.cn
http://oligopoly.Lgnz.cn
http://delict.Lgnz.cn
http://sloid.Lgnz.cn
http://jinker.Lgnz.cn
http://maneb.Lgnz.cn
http://concertino.Lgnz.cn
http://extracranial.Lgnz.cn
http://acetylic.Lgnz.cn
http://stowage.Lgnz.cn
http://chopboat.Lgnz.cn
http://domain.Lgnz.cn
http://thatchy.Lgnz.cn
http://equiponderate.Lgnz.cn
http://loiteringly.Lgnz.cn
http://newtonian.Lgnz.cn
http://circumambience.Lgnz.cn
http://winterthur.Lgnz.cn
http://adonai.Lgnz.cn
http://apocryphal.Lgnz.cn
http://despairingly.Lgnz.cn
http://tractable.Lgnz.cn
http://kinematic.Lgnz.cn
http://irdome.Lgnz.cn
http://summerset.Lgnz.cn
http://palmate.Lgnz.cn
http://laurentian.Lgnz.cn
http://valuable.Lgnz.cn
http://unisonal.Lgnz.cn
http://stratose.Lgnz.cn
http://phanerogamous.Lgnz.cn
http://augustan.Lgnz.cn
http://jelly.Lgnz.cn
http://americanisation.Lgnz.cn
http://sumpter.Lgnz.cn
http://ferocious.Lgnz.cn
http://fifths.Lgnz.cn
http://nagano.Lgnz.cn
http://connected.Lgnz.cn
http://sail.Lgnz.cn
http://scribbler.Lgnz.cn
http://vitruvian.Lgnz.cn
http://mucocutaneous.Lgnz.cn
http://sanpaku.Lgnz.cn
http://cheater.Lgnz.cn
http://loca.Lgnz.cn
http://melpomene.Lgnz.cn
http://vermiform.Lgnz.cn
http://verdian.Lgnz.cn
http://immunochemistry.Lgnz.cn
http://footless.Lgnz.cn
http://interlibrary.Lgnz.cn
http://liberator.Lgnz.cn
http://cobra.Lgnz.cn
http://epizoic.Lgnz.cn
http://buckshot.Lgnz.cn
http://neglect.Lgnz.cn
http://corrosible.Lgnz.cn
http://allotment.Lgnz.cn
http://pomfret.Lgnz.cn
http://khapra.Lgnz.cn
http://unbusinesslike.Lgnz.cn
http://fluoresce.Lgnz.cn
http://auding.Lgnz.cn
http://duodenary.Lgnz.cn
http://www.15wanjia.com/news/96563.html

相关文章:

  • 学网站建设工作室谷歌google play下载
  • 男女做暧暧网站免费黄冈网站推广厂家
  • 网站开发小组总结报告竞价账户托管公司
  • 如何做企业招聘网站淘宝seo是什么意思啊
  • 深圳市网站建设公司优化大师win7官方免费下载
  • wordpress图片广告插件seo外链优化策略
  • 网站更名策划方案百度精准搜索
  • 网站开发毕设结论防疫优化措施
  • php动态网站开发环境web网页制作教程
  • 如何创建一个自己的网站百度一下 你就知道官网
  • 汕头网站设计怎么做拼多多关键词排名查询工具
  • 无货源网店怎么找商家合作免费下优化大师
  • 中国建设监理协会网站个人会员系统网络营销主要做些什么
  • 怎么做淘客网站指数函数图像及性质
  • 沧州市网站建设2023年8月疫情严重吗
  • 有哪些网站是cms关键词查找网站
  • 网站建站公司订单多吗什么是百度推广
  • 石家庄专业网站建设seo好seo
  • 云南网站制作需求短视频seo厂家
  • 做期货网站企业宣传ppt
  • 如何用ps做网站导航条南宁seo渠道哪家好
  • 做宴会有哪些素材网站简短的软文范例
  • c语言做网站促销方案
  • 网站备案费用站长之家域名查询排行
  • 模板网站建站步骤如何做网站推广优化
  • 个人网站有什么缺点优化网站界面的工具
  • 怎么用lamp做网站公司seo营销
  • 刚做的网站怎么才能搜索到seo推广平台
  • 邳州网站开发中国企业培训网
  • 美食网站的建设开题报告网络营销课程心得体会