首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

请问下selffacotry的有关问题

2011-12-30 
请教下selffacotry的问题今天看别人代码, 看到这么一段public Object selfFactory() {Class cl this.get

请教下selffacotry的问题
今天看别人代码, 看到这么一段

public Object selfFactory() {
Class cl = this.getClass();
Constructor cons;

try {
cons = cl.getConstructor(null);
} catch(SecurityException e) {
throw new RuntimeException(e);
} catch(NoSuchMethodException e) {
throw new RuntimeException(e);
}

try {
return cons.newInstance(null);
} catch(IllegalArgumentException e1) {
throw new RuntimeException(e1);
} catch(InstantiationException e1) {
throw new RuntimeException(e1);
} catch(IllegalAccessException e1) {
throw new RuntimeException(e1);
} catch(InvocationTargetException e1) {
throw new RuntimeException(e1);
}
}

请教一下, 这个selffactory() 是属于那一种模式的应用么?作用是什么? 谢谢指教

[解决办法]
这个类是做基类用的?
[解决办法]
反射,返回本类的一个实例

[解决办法]

探讨
反射,返回本类的一个实例

热点排行