java数组叠加问题.有个较大的字节数组 byte[] total=new byte[12]这里有个三个临时的小的字节数组 byte[] a和 byte[] b 以及 byte[] c,每个只有4个字节,java中如何写更简单,效率更好的将三个小的放到total中。
解决方案 »
- null能不能作为方法的参数
- 今年的巴德歌赫猜想,谁答出,谁有奖
- 执行TOMCAT5.0.16 startup应用程序时,一闪而过。而用startup.bat时则可以启动
- Why my applet not inited?
- 关于Socket及线程简单问题(急!)
- 我知道这个问题很简单,但是真的不会,而且很急
- 征求彩蛋意见(暨节后散分)
- VisualAge跟jbuilder,谁好?
- 关于本地方法调用,是linux下的。
- sharetop(天生不笨) 朋友来看。谢谢。。。。
- 如何获取IP地址对应的MAC地址
- 取代new sun.misc.BASE64Encoder().encode的新的API是什么?TKS
for(int i=0;i<12;i++){
total[i]=tmp[i/4][i%4];
}
System.arraycopy(a, 0, total, 0, a.length);
System.arraycopy(b, 0, total, a.length, b.length);
System.arraycopy(c, 0, total, a.length+b.length, c.length);
public static void main(String[] args) {
byte[] total = fill(null, new byte[]{1,2,3,4});
total = fill(total, new byte[]{5,6,7,8});
total = fill(total, new byte[]{9,10,11,12}); System.out.println(ArrayUtils.toString(total));
} public static byte[] fill(byte[] total, byte[] temp){
return ArrayUtils.addAll(total,temp);
}
byte[] total = new byte[12];
byte[] a = new byte[] { 1, 2, 3, 4 };
byte[] b = new byte[] { 4, 5, 6, 7 };
byte[] c = new byte[] { 8, 9, 10, 11 }; System.arraycopy(a, 0, total, 0, 4);
System.arraycopy(b, 0, total, 4, 4);
System.arraycopy(c, 0, total, 8, 4);
}
}