当前位置:网站首页>反射三种方式
反射三种方式
2022-06-11 02:32:00 【ambition_forever】
public class ReflectionDemo {
public static void main(String[] args) {
Class <?> cls = String.class; //仅适合在编译前就已经明确要操作的 Class
try{ //已明确类的全路径名
Class <?> c= Class.forName("java.lang.String");
String s=(String)c.newInstance();
}catch(Exception e){
System.out.println(e.getMessage());
}
//3、适合有对象示例的情况下
String str = new String();
System.out.println(str.getClass());
}
}
边栏推荐
- Common vocabulary of software testing English
- Will your company choose to develop data center?
- AOSP ~ WIFI默认开启 + GPS默认关闭 + 蓝牙默认关闭 + 旋转屏幕关闭
- MySQL backup and recovery
- 【189. 轮转数组】
- How to read PMBOK guide in 3 steps (experience + data sharing)
- Why did those who left Beijing, Shanghai and Guangzhou with a smile cry in the end?
- Write my Ini configuration file error
- OpenJudge NOI 1.13 17:文字排版
- 【新晋开源项目】动态配置化任务编排框架 Gobrs-Async 加入Dromara开源社区
猜你喜欢

Will your company choose to develop data center?

Blue Bridge Cup_ Xiao Lan eats candy_ Pigeon nest principle / drawer principle

軟件測試英語常見詞匯

helm 部署traefik ingress

软件测试英语常见词汇

How to add cookie pop-up window in WordPress website (without plug-in)

How to use phpMyAdmin to optimize MySQL database

A collection of common ADB commands for app testing

JS memory leak

One line of code solves the problem that the time to fetch datetime from MySQL database is less than eight hours
随机推荐
Common vocabulary of software testing English
Prophet
第七章 常用的协议简介(1)
GCC C inline assembly
【斐波那契数列】
AOSP ~ 修改默认音量
How to state clearly and concisely the product requirements?
OpenJudge NOI 1.13 18:Tomorrow never knows?
【大咖秀】博睿数据眼中的AIOps,选择正确的赛道正确的人
Explanation of spark common parameters
Win10 安装Office 2016出现错误代码30204-44怎么处理?
One line of code solves the problem that the time to fetch datetime from MySQL database is less than eight hours
jdbc工具类的问题
ADVANCE. AI CEO Shoudong will share the compliance of cross-border e-commerce using AI technology at the 2022 emerging market brands online Summit
AOSP ~ modify WebView default implementation
逃离大城市的年轻人:扛住了房价和压力,没扛住流行病
CPT 102_ LEC 13-14
The new colleague asked me what "where 1=1" means???
怎样简洁明了地说清楚产品需求?
弄懂了采矿业与碳中和的逻辑,就读懂了矿区无人驾驶的千亿市场