Eiseno 于 2012.12.24 16:24 提问

5个回答

niangzhi   2012.12.25 15:29

``````array1.addAll(array2);
``````

``````Something like this:
if (array1.length() != array2.length()) { // Too many names, or too many numbers
// Fail
}
ArrayList<String> array3 = new ArrayList<String>(); // Make a new list
for (int i = 0; i < array1.length(); i++) { // Loop through every name/phone number combo
array3.add(array1.get(i) + " " + array2.get(i)); // Concat the two, and add it
}
``````

``````array1 : ["a", "b", "c"]
array2 : ["1", "2", "3"]
``````

``````array3 : ["a 1", "b 2", "c 3"]
``````
kfanning   2013.07.23 11:11

``````public static void main(String[] args) {
String[] nameArray = new String[]{"张三","李四","赵武"};
long[] phoneNumArray = new long[]{11111111111l,22222222222l,22222222222l};
Object[] mixArray = new Object[]{nameArray , phoneNumArray};
for (int i = 0 , j = Array.getLength(mixArray[0]); i < j; i++) {
System.out.println(Array.get(mixArray[0], i) +"的电话号码为:" + Array.getLong(mixArray[1], i));
}
}
``````

``````张三的电话号码为:11111111111

``````
yiranwujixian   2012.12.24 16:48
``````ArrayList<String> resultList = new ArrayList<String>();
``````
Sueyexin   2012.12.25 15:04

``````Arraylist1.addAll(Arraylist2);
``````

``````ArrayList<String> arraylist3=new ArrayList<String>();