集册 Java实例教程 合并两个字符串数组

合并两个字符串数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

416
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
合并两个字符串数组
//N o  w  J a v a . c o m - 时  代  Java 提供


//package com.book2s;


public class Main {

    public static void main(String[] argv) {

        String[] pa = new String[] { "1", "abc", "level", null,

                "book2s.com", "asdf 123" };

        String[] pb = new String[] { "1", "abc", "level", null,

                "book2s.com", "asdf 123" };

        System.out.println(java.util.Arrays.toString(mergeTwoStringArrays(

                pa, pb)));

    }


    public static String[] mergeTwoStringArrays(String[] pa, String[] pb) {


        if (pa == null)

            return pb;


        if (pb == null)

            return pa;
/*from N o w J a v a . c o m - 时代Java*/

        String[] arr = new String[pa.length + pb.length];

        for (int x = 
展开阅读全文