下面的java代码存在,但我试图将其转换为groovy。我应该保持它与System.arraycopy一样吗?还是groovy有更好的方法来组合这样的数组?如何在groovy中组合数组?
byte[] combineArrays(foo, bar, start) {
def tmp = new byte[foo.length + bar.length]
System.arraycopy(foo, 0, tmp, 0, start)
System.arraycopy(bar, 0, tmp, start, bar.length)
System.arraycopy(foo, start, tmp, bar.length + start, foo.length - start)
tmp
}
谢谢
你不使用列表有什么特别的原因吗? – 2011-02-04 19:51:03
如果你打算使用数组,我会保持这样的...没有任何意义的数组转换成列表,然后再返回只是使用一些时髦的风格 – 2011-02-05 13:54:45