集册 Java实例教程 连接对象数组

连接对象数组

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

647
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
连接对象数组


//package com.nowjava;

/*
时代Java公众号 提供
*/

public class Main {

    public static void main(String[] argv) throws Exception {

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

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

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

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

        System.out

                .println(java.util.Arrays.toString(connectArrays(a1, a2)));

    }


    public static Object[] connectArrays(Object[] a1, Object[] a2) {

        Object[] ret = new Object[a1.length + a2.length];

        for (int i = 0; i < a1.length; i++) {

            ret[i] = a1[i];

        }

        
展开阅读全文