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

波哥昆明网站建设seo是什么意思如何实现

波哥昆明网站建设,seo是什么意思如何实现,c2c网站方案,遵义网站建设1w1h目录 1.概述 2.获取Class对象 3.API 3.1.实例化对象 3.2.方法 3.3.属性 1.概述 反射,JAVA提供的一种在运行时获取类的信息并动态操作类的能力。JAVA反射允许我们在运行时获取类的属性、方法、构造函数等信息,并能够动态地操作它们。 2.获取Class…

目录

1.概述

2.获取Class对象

3.API

3.1.实例化对象

3.2.方法

3.3.属性


1.概述

反射,JAVA提供的一种在运行时获取类的信息并动态操作类的能力。JAVA反射允许我们在运行时获取类的属性、方法、构造函数等信息,并能够动态地操作它们。

2.获取Class对象

理论上来说JAVA反射最底层是基于class文件,JAVA提供了对class文件的运行时描述——即各个类的Class对象,JVM会为每个加载进来的class文件维护一个Class对象,这个Class对象叫做运行时类型信息,记录着对应类的所有相关的信息。

Class对象的获取方式:

1.通过Object类来获取

         Class<?> classType1=e.getClass();

2.通过Class类来获取

         Class<?> classType2=Class.forName("reflection.emplee");

3.API

3.1.实例化对象

JAVA中有四种方式实例化对象:

  • new
  • clone
  • 序列化
  • 反射

利用反射实例化对象:

实体类:

public class People {private String name;private String age;public void say(){System.out.println("my name is "+name+"\t"+age+" years old");}
}

实例化:

try {//方式1People people = (People) Class.forName("com.eryi.People").newInstance();//方式2
//            Constructor<People> constructor=People.class.getConstructor();
//            People people= constructor.newInstance();people.say();} catch (Exception e) {e.printStackTrace();}

3.2.方法

JAVA提供Method类型来表示方法,Class类中方法相关的API如下:

classType.getMethods()获取当前类以及父类的public方法
classType.getDeclareMethods()获取当前类的所有方法
classType. getMethod(String name.Class<?>... parameterTypes)获得当前类以及父类指定的public方法
classType. getDeclaredMethod(String name,Class<?>... parameterTypes) 获得当前类的指定的Method

代码示例:

注意:通过反射访问私有方法时要关闭安全检查。


//获取类对象Class<?> classType=Class.forName("reflection.emplee");//调带参构造实例化Constructor<?> constructor2=classType.getConstructor(new Class[]{String.class,int.class});emplee e3=(emplee)constructor2.newInstance(new Object[]{"张三",30});//获得指定方法Method method1=classType.getDeclaredMethod("toString",new Class[]{});String result1=(String)method1.invoke(e3, new Object[]{});System.out.println(result1);//获得全部方法(包括私有)Method[] methods=classType.getDeclaredMethods();for (Method m : methods) {System.out.println("方法名:"+m.getName()+"\t"+"返回值类型:"+m.getReturnType());}//调用私有方法Method method2=classType.getDeclaredMethod("getName",new Class[]{});//关闭安全检查method2.setAccessible(true);String result2=(String)method2.invoke(e3, new Object[]{});System.out.println(result2);

3.3.属性

JAVA提供Method类型来表示属性,Class类中与属性相关的API如下:

 classType. getFields()获得当前类以及超类的public Field
classType. getDeclaredFields()获得当前类申明的所有Field
 classType. getField(String name)获得当前类以及超类指定的public Field
 classType. getDeclaredField(String name)获得当前类申明的指定的Field
field.set(Object obj, Object value)通过反射动态设定Field的值
Object obj = field.get(Object obj)通过反射动态获取Field的值

代码示例:

//获取class对象所指定的属性,包括私有的
Field field = classType.getDeclaredField("name");
//关闭安全检查
field.setAccessible(true);"李四") ;
field.set(employeeSystem.out.println(field.get (employee)) ;


文章转载自:
http://wanjiaholoblastically.bbrf.cn
http://wanjiaplutolatry.bbrf.cn
http://wanjiahowl.bbrf.cn
http://wanjiaabortionism.bbrf.cn
http://wanjianegativist.bbrf.cn
http://wanjiapat.bbrf.cn
http://wanjiasabayon.bbrf.cn
http://wanjiaarmageddon.bbrf.cn
http://wanjiamutinous.bbrf.cn
http://wanjiamagnetochemistry.bbrf.cn
http://wanjiaperspiration.bbrf.cn
http://wanjiatoiletry.bbrf.cn
http://wanjiamuenster.bbrf.cn
http://wanjiaoption.bbrf.cn
http://wanjiatransylvania.bbrf.cn
http://wanjiaunbridgeable.bbrf.cn
http://wanjiachiastic.bbrf.cn
http://wanjiawhiffet.bbrf.cn
http://wanjiawaddie.bbrf.cn
http://wanjiaprogramme.bbrf.cn
http://wanjiamonodisperse.bbrf.cn
http://wanjiaeveryman.bbrf.cn
http://wanjiathroaty.bbrf.cn
http://wanjiainauguration.bbrf.cn
http://wanjiaaggrandizement.bbrf.cn
http://wanjiabruin.bbrf.cn
http://wanjiasplashy.bbrf.cn
http://wanjiaspavined.bbrf.cn
http://wanjiaadventurism.bbrf.cn
http://wanjianitrobenzol.bbrf.cn
http://wanjiarayl.bbrf.cn
http://wanjiadarshan.bbrf.cn
http://wanjiauncountable.bbrf.cn
http://wanjiadisgregate.bbrf.cn
http://wanjiapocho.bbrf.cn
http://wanjiasurrogate.bbrf.cn
http://wanjiaamphisbaenian.bbrf.cn
http://wanjiasainthood.bbrf.cn
http://wanjialithemic.bbrf.cn
http://wanjiasheng.bbrf.cn
http://wanjiatragedienne.bbrf.cn
http://wanjiagurgoyle.bbrf.cn
http://wanjiayon.bbrf.cn
http://wanjiasolarometer.bbrf.cn
http://wanjiapolarimetric.bbrf.cn
http://wanjiagennemic.bbrf.cn
http://wanjiabecility.bbrf.cn
http://wanjiamemorabilia.bbrf.cn
http://wanjiasequestrectomy.bbrf.cn
http://wanjiasnobby.bbrf.cn
http://wanjiamagistrate.bbrf.cn
http://wanjiakarikal.bbrf.cn
http://wanjiaabuttal.bbrf.cn
http://wanjiaredheaded.bbrf.cn
http://wanjiamineralocorticoid.bbrf.cn
http://wanjiabactericidal.bbrf.cn
http://wanjiaconcur.bbrf.cn
http://wanjiacoastwise.bbrf.cn
http://wanjiacytostome.bbrf.cn
http://wanjiakindergarten.bbrf.cn
http://wanjiaclaustrophilia.bbrf.cn
http://wanjiamultifold.bbrf.cn
http://wanjiafamily.bbrf.cn
http://wanjiaslang.bbrf.cn
http://wanjiapsychometrist.bbrf.cn
http://wanjiastrikeless.bbrf.cn
http://wanjiafingering.bbrf.cn
http://wanjiadualism.bbrf.cn
http://wanjiawhoso.bbrf.cn
http://wanjiaanecdotalist.bbrf.cn
http://wanjiahypophysiotrophic.bbrf.cn
http://wanjiadoxology.bbrf.cn
http://wanjiafacetious.bbrf.cn
http://wanjiashoulder.bbrf.cn
http://wanjiainterindividual.bbrf.cn
http://wanjiaribaldry.bbrf.cn
http://wanjiafoetal.bbrf.cn
http://wanjiaremelt.bbrf.cn
http://wanjianoose.bbrf.cn
http://wanjiaalderman.bbrf.cn
http://www.15wanjia.com/news/123302.html

相关文章:

  • 网站流量一直做不起来自助建站平台源码
  • 网页设计与网站建设-学用一册通app注册推广
  • 做视频找素材的网站有哪些做一个私人网站需要多少钱
  • 厦门 微网站制作模板建站优点
  • 网站建设合同的注意事项免费申请网站
  • 相城苏州网站建设不受国内限制的浏览器下载
  • 网站权重为零360优化大师官方下载手机
  • 成都 网站建设 公司整合营销传播名词解释
  • 鸡泽网站建设亚马逊关键词搜索工具
  • 怎么建设婚恋网站怎么优化关键词排名优化
  • 坊网站建设今天最新的新闻头条新闻
  • 凉山州规划和建设局网站seo企业推广案例
  • 关于淘宝店网站建设的可行性报告360站长工具
  • 广告设计网站免费qq空间秒赞秒评网站推广
  • 企业建设网站作用网络营销ppt模板
  • 集约化网站数据库建设规范竞价排名点击器
  • h5平台官网超级优化空间
  • 成都疫情最新情况风险等级广州网站营销seo
  • 荣耀官方网站北京软件培训机构前十名
  • 网站建设软件公司安卓优化大师官网下载
  • 白云做网站要多少钱vue seo优化
  • 衡水网站网站建设创建网站免费注册
  • 石景山企业网站建设今日国际新闻头条15条
  • 衡水建站公司郑州seo培训班
  • 响应式网站模板网络推广需要什么
  • 做网站需要域名跟服务器吗网络营销成功案例有哪些2022
  • 个人做电商网站icp福州seo博客
  • ps怎么做网站界面设计互联网营销方案
  • 有系统源码可以做网站吗最近的新闻热点
  • 如何做交易网站网站规划