java string array merge How to merge into one array?

java string array merge, you can use array.copy copy method, the following code:

package?com.qiu.lin.he;

import?java.text.ParseException;

import?java. util.Arrays;

public?class?Ceshi?{

public?static?void?main(String[]?args)?throws?ParseException?{

String[]?str1?= ? {?" J",?" a",?" v",?" a",?" in"?} ;

String[]?str2?=? {?" As ",?" why ",?" put ",?" two ",?" One",?" Numbers,? Grouped together. Combine them. and ",?" for ",

"a",?" a "?} ;

int?strLen1?=?str1.length;//? Holds the first array length

int?strLen2?=?str2.length;//? Holds the second array length

str1?=?Arrays.copyOf(str1,?strLen1?+?strLen2);//? Expand

System.arraycopy(str2,?0,?str1,?strLen1,?strLen2);//? Merge the second array with the first

System.out.println(Arrays.toString(str1));//? Output the array

}

}

The result of the run is as follows: