相关疑难解决方法(0)

为什么Class.newInstance()"邪恶"?

瑞安DELUCCHI问这里的评论#3 汤姆Hawtin的回答是:

为什么Class.newInstance()"邪恶"?

这是为了响应代码示例:

// Avoid Class.newInstance, for it is evil.
Constructor<? extends Runnable> ctor = runClass.getConstructor();
Runnable doRun = ctor.newInstance();
Run Code Online (Sandbox Code Playgroud)

那么,为什么它是邪恶的?

java constructor runtime instantiation

91
推荐指数
3
解决办法
7万
查看次数

标签 统计

constructor ×1

instantiation ×1

java ×1

runtime ×1