public class Test_Str{
public static void main(String[] args){
String[] str_1={"1","2","3","4","5","6","7"};
String[] str_2={"a","b","c","d","e","f","g"};
String[] str_3=new String[str_1.length+str_2.length];
System.out.println(" str_1 = "+str_1.length);
System.out.println(" str_2 = "+str_2.length);
System.out.println(" str_3 = "+str_3.length);
System.arraycopy(str_1,0,str_3,0,str_1.length);
System.arraycopy(str_2,0,str_3,str_1.length,str_2.length);
for(int i=0;i<str_3.length;i++){
System.out.println(" str_3["+i+"] = "+str_3[i]);
}
}
}
public static void main(String[] args){
String[] str_1={"1","2","3","4","5","6","7"};
String[] str_2={"a","b","c","d","e","f","g"};
String[] str_3=new String[str_1.length+str_2.length];
System.out.println(" str_1 = "+str_1.length);
System.out.println(" str_2 = "+str_2.length);
System.out.println(" str_3 = "+str_3.length);
System.arraycopy(str_1,0,str_3,0,str_1.length);
System.arraycopy(str_2,0,str_3,str_1.length,str_2.length);
for(int i=0;i<str_3.length;i++){
System.out.println(" str_3["+i+"] = "+str_3[i]);
}
}
}
本文转自博客园执着的笨蛋的博客,原文链接:字符串数组连接例子(原创),如需转载请自行联系原博主。