用OO思想优化代码

06-05-27 xjde1314
public Object createCopy(Object source) {

if (source instanceof Integer) {

return new Integer(((Integer)source).intValue());

}

if (source instanceof Long) {

return new Long(((Long)source).longValue());

}

if (source instanceof Float) {

return new Float(((Float)source).floatValue());

}

return null;

}

banq
2006-05-29 15:37
用这么长if else就不是OO了吧?

猜你喜欢