Question: I have the following array:

```
int nums[] = new int[]{1,2,3,4,5};

```

I want to add the same elements to the array using stream or another proper way if it is better using stream. There is `addAll()` method for `List`, but I could not use it for array and I am not sure if there is a proper way for array. So, how can I convert this list to:

```
int nums[] = new int[]{1,2,3,4,5,1,2,3,4,5};

```

Answer: 
Iterative or stream based solutions are unnecessarily complicated and slow. Just use `System.arraycopy`:

```java
public class Test {
    public static void main(String[] args) {

        int[] a = {1,2,3,4,5};
        int[] b = {6,7,8,9,10};

        int[] aAndB = new int[a.length + b.length];
        System.arraycopy(a, 0, aAndB, 0, a.length);
        System.arraycopy(b, 0, aAndB, a.length, b.length);

        System.out.println(Arrays.toString(aAndB));
    }
}

```

`System.arraycopy` is highly optimised: [Why is System.arraycopy native in Java?](https://stackoverflow.com/questions/2772152/why-is-system-arraycopy-native-in-java)
how about using `Arrays.copyOf(arg, arg)`?

```
public static void main(String[] args) {
 int[] nums = new int[]{1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
 int[] copiedArray = Arrays.copyOf(nums, nums.length);
}

```

If you really want to use Stream,

```
public static void main(String[] args) {
 int[] nums = new int[]{1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
 int[] copiedArray = Arrays.stream(nums).toArray();
}

```