LoginSignup
11
9

More than 5 years have passed since last update.

Java の arraycopy メソッドの引数は「元配列、元開始位置、先配列、先開始位置、個数」の順で「上書き」

Last updated at Posted at 2016-04-21

いつも忘れるので備忘録的メモ。

ArrayCopy.java
import java.util.Arrays;

public class ArrayCopy {
  public static void main(String[] args) {
    int[] array = {1, 2, 3, 4, 5};
    System.out.println(Arrays.toString(array));
    System.arraycopy(array, 2, array, 1, 2);
    System.out.println(Arrays.toString(array));
  }
}

[1, 2, 3, 4, 5]
[1, 3, 4, 4, 5]

と表示されます。

実験はこちら

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9