- Joined
- Jul 6, 2007
- Messages
- 2
- Reaction score
- 0
appendArrays (use addAll not add)
I think you meant to use addAll, as in:
/**
* @param array1
* @param array2
* @return a new array containing the contents of array1 followed by the contents of array2.
*/
public String[] appendArrays (String[]array1, String[] array2) {
ArrayList<String> temp =
new ArrayList<String>(array1.length + array2.length);
temp.addAll(Arrays.asList(array1));
temp.addAll(Arrays.asList(array2));
String[] result = (String[]) temp.toArray(new String[temp.size()]);
return result;
}
I think you meant to use addAll, as in:
/**
* @param array1
* @param array2
* @return a new array containing the contents of array1 followed by the contents of array2.
*/
public String[] appendArrays (String[]array1, String[] array2) {
ArrayList<String> temp =
new ArrayList<String>(array1.length + array2.length);
temp.addAll(Arrays.asList(array1));
temp.addAll(Arrays.asList(array2));
String[] result = (String[]) temp.toArray(new String[temp.size()]);
return result;
}