java拨钟
发布时间: 2024-07-16 21:16:09
Ⅰ java字符串数组合并 怎么合并成一个数组
java字符串数组合并,可以使用array.复制方法,如下代码:
packagecom.qiu.lin.he;
importjava.text.ParseException;
importjava.util.Arrays;
publicclassCeshi{
publicstaticvoidmain(String[]args)throwsParseException{
String[]str1={"J","a","v","a","中"};
String[]str2={"如","何","把","两","个","数","组","合","并","为",
"一","个"};
intstrLen1=str1.length;//保存第一个数组长度
intstrLen2=str2.length;//保存第二个数组长度
str1=Arrays.Of(str1,strLen1+strLen2);//扩容
System.array(str2,0,str1,strLen1,strLen2);//将第二个数组与第一个数组合并
System.out.println(Arrays.toString(str1));//输出数组
}
}
运行结果如下:
热点内容