Current location - Health Preservation Learning Network - Fitness coach - How to merge java string arrays into one array?
How to merge java string arrays into one array?
Java string array merge, you can use array.copy copy method, the following code:

Parcel? com . Qiu . Lin . he;

Import? Java . text . parse exception;

Import? Java . util . array;

Public? Class? Shi Ce? {

Public? Static electricity Invalid? main(String[]? args)? Throwing? ParseException? {

String[]? str 1? =? {? “J”,? One. “v”,? One. "Medium"? };

String[]? str2? =? {? "Like"? "what"? "ba" "two" a。 "Numbers"? "Group" and "Together"? "and"? "for",

"one" and "one" };

int? strLen 1? =? str 1 . length; //? Save the length of the first array.

int? strLen2? =? str2.length//? Save the length of the second array.

str 1? =? Arrays.copyOf(str 1,strLen 1? +? strlen 2); //? Expand telecom capacity

System.arraycopy(str2,0,? str 1,? strLen 1,? strlen 2); //? Merge the second array with the first array.

system . out . println(arrays . tostring(str 1)); //? Output array

}

} The running results are as follows: