I need to concatenate two String arrays in Java.
void f(String[] first, String[] second) { String[] both = ??? }
What is the easiest way to do this?
Sommaire |
I need to concatenate two String arrays in Java.
void f(String[] first, String[] second) { String[] both = ??? }
What is the easiest way to do this?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/commons/lang3/ArrayUtils.html#addAll%28T%5B%5D,%20T...%29 http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/commons/lang3/ArrayUtils.html#addAll%28T%5B%5D,%20T...%29
Code:
String[] both = (String[])ArrayUtils.addAll(first, second);
License : cc by-sa 3.0
http://stackoverflow.com/questions/80476/how-can-i-concatenate-two-arrays-in-java