获取class对象,有三种方法:

1.通过类名.class直接访问

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

Class c = Integer.class;

2.通过Class.forName(类名)函数获取

Class c = Class.forName("Integer");

 

3.通过对象.class获取

Integer n = new Integer ();

Class c = n.getClass();

 

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄