![](/img/trans.png)
[英]copy specific row from one 2D array to another without system.arraycopy
[英]How to copy a row from a 2d array to another
嗨,我有一個大型2D數組( sample[1000][10]
)。 我想知道如何將最后一行(1000)復制到2d臨時數組( temp[1][10]
)中?
編輯:我嘗試了以下但我想知道是否有更快的代碼:
for (int i = 0; i < 10; i++){
temp[0][i] = sample[sample.length - 1][i];
}
使用System.arraycopy
:
System.arraycopy(sample[999], 0, temp[0], 0, 10);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.