java – An easy way to concatenate arrays of strings


Good day!

I need to concatenate two arrays of string type, in what simple way can I do this?

String[] bothArray(String[] first, String[] second) {
    return ??;


If Java8 is allowed , then you can use the Stream class and lambdas:

import java.util.Arrays;

// . . .

String[] bothArray(final String[] first, final String[] second)
    return Stream.concat(Stream.of(first), Stream.of(second)).toArray(String[]::new);

Compact, beautiful and requires no external components.

Scroll to Top