Java - Write code to merge Array

Requirements

Write code to merge Array

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String[] a = new String[] { "1", "abc", "level", null,
                "book2s.com", "asdf 123" };
        String[] b = new String[] { "1", "abc", "level", null,
                "book2s.com", "asdf 123" };
        System.out.println(java.util.Arrays.toString(mergeArray(a, b)));
    }/*from   www  .j  a v  a  2s .co  m*/

    public static String[] mergeArray(String[] a, String[] b) {
        if (a == null) {
            return b;
        }
        if (b == null) {
            return a;
        }
        String[] newArray = new String[a.length + b.length];
        System.arraycopy(a, 0, newArray, 0, a.length);
        System.arraycopy(b, 0, newArray, a.length, b.length);
        return newArray;
    }
}