日期:2014-05-20  浏览次数:20639 次

关于两个byte[]数组合并的问题

byte[] bb ={2};
byte[] cc ={1};
byte[] dd =new byte[bb.length+cc.length];
for(int i=0;i<dd.length;i++){
if(i<bb.length){
dd[i]=bb[i];
}
else{
dd[i]=cc[i-bb.length];
}
}

这是for、if实现的。我想知道java里面有没有类可以直接实现
------最佳解决方案--------------------
System.arrayCopy
------其他解决方案--------------------
引用:
System.arrayCopy

+1
http://topic.csdn.net/t/20031225/15/2602270.html
------其他解决方案--------------------
引用:
引用:
System.arrayCopy

+1
http://topic.csdn.net/t/20031225/15/2602270.html


多谢了,下次我会先多找找的。
------其他解决方案--------------------
引用:
System.arrayCopy

顺便说一下是这样的System.arraycopy
------其他解决方案--------------------
我只想说这只能copy不能改变数组长度!对于一楼的方法,只完成了一半。