Vector 的clone方法

lbingt 2010-03-10 09:28:29
有没有那位有具体的关于Vector的clone方法,给推荐个,最好是源码
...全文
128 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
soulx 2010-03-11
  • 打赏
  • 举报
回复

/**
* Returns a clone of this vector. The copy will contain a
* reference to a clone of the internal data array, not a reference
* to the original internal data array of this <tt>Vector</tt> object.
*
* @return a clone of this vector.
*/
public synchronized Object clone() {
try {
Vector<E> v = (Vector<E>) super.clone();
v.elementData = new Object[elementCount];
System.arraycopy(elementData, 0, v.elementData, 0, elementCount);
v.modCount = 0;
return v;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}


JDK中的源码

复制了一个具有同样状态的对象。
kf156 2010-03-11
  • 打赏
  • 举报
回复
Vector

public Object clone()返回向量的一个副本。副本中将包含一个对内部数据数组克隆的引用,而非对此 Vector 对象的原始内部数据数组的引用。

覆盖:
类 Object 中的 clone
返回:
向量的一个副本。
另请参见:
Cloneable
ublearning 2010-03-11
  • 打赏
  • 举报
回复
看jdk的源码~~~~~~~~~
lbingt 2010-03-11
  • 打赏
  • 举报
回复
唉,现在只记得看j2me的MID Profile 文档,忘记了java自己的api文档了,杯具啊......

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧