如何在Java中合并两个对象数组 [英] How to combine two object arrays in Java

查看:93
本文介绍了如何在Java中合并两个对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个小脚本,可以从excel文件中获取信息.收集完所需的信息后,我想将这两个数组合并为一个.有可能吗?

I have this little script that gets information from an excel file. After I've collected the information that i need i want to combine these two arrays into one. Is that possible?

public Object[][] createData1() throws Exception {
    Object[][] retObjArr1 = data.getTableArray("C:\\Users\\OAH\\Workspaces\\Chrome2\\Testdata2.xls", "Sheet1", "normalCustomer");
    Object[][] retObjArr2 = data.getTableArray("C:\\Users\\OAH\\Workspaces\\Chrome2\\Testdata2.xls", "Sheet2", "langLogin");
    return(retObjArrCombined); //I want to return one array with both arrays
}

推荐答案

您可以使用 System.arraycopy 方法(是,全部为小写).

You can use the System.arraycopy method (yes, all lowercase). Javadoc. You can do more stuff with arrays using the java.util.Arrays class.

这篇关于如何在Java中合并两个对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆