How can I concatenate two arrays in Java

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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?

Answers

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);

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/80476/how-can-i-concatenate-two-arrays-in-java

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils