JiveJdon Community Forums
在线52人   首页   主题总表   培训咨询   精华   查搜   注册    登陆
首页 » 论坛 » J2EE/JavaEE/JEE/EJB/JSF等技术讨论
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 2 回复 / 1
 发表新帖子   回复该主题贴
banq

悄悄话
发表文章: 9290
注册时间: 2002年08月03日 17:08
基础:如何有效的拷贝和合并数组 2002年12月03日 15:18 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
数组操作快,很多人喜欢用,但数组是定长的,难以动态扩展,一般用合并数组的办法。使用clone比较好实现数组拷贝:

英文:

It is ok to use clone() for arrays. In the case of arrays that are not of
primitive types, It does a "shallow:" copy meaning it doesn't copy the
objects that are referenced in the array. This is important in the case of
multi-dimensioned arrays. Because they also are just arrays of objects, the
sub-arrays don't get copied.

Use clone() only when you want to create an exact copy of the array, i.e.
same size, same element type.

System.arraycopy works on two existing arrays, so if you use that, you have
to create an empty array first. You would use it if you wanted to copy the
contents of an array to a bigger array (thereby "growing" the array) or if
you want to create an array where the element type is assignment-compatible
with the original array (e.g. going from String[] to Object[]). You can also
use it to move array elements within an array.
nmg

悄悄话
发表文章: 55
注册时间: 2002年12月02日 09:45
Re: 基础:如何有效的拷贝和合并数组 2002年12月03日 15:55 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
可以用ArrayList 呀,
java.lang.Object
|
+-java.util.AbstractCollection
|
+-java.util.AbstractList
|
+-java.util.ArrayList

banq

悄悄话
发表文章: 9290
注册时间: 2002年08月03日 17:08
Re: 基础:如何有效的拷贝和合并数组 2002年12月04日 15:24 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
不知道arrayList和array之间的转换在性能要求极高系统中是否耗时?

我觉得array定为原始元素,是java的一个败笔,据说Jdk1.5会改变。
这个主题有 2 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam