java合并两个String数组

public static void main(String[] args) {
		String [] arry1 = {"A","B","C","D","E"};
		String [] arry2 = {"F","G","H","I","J"};
		int arryLen1=arry1.length;//获取第一个数组长度
		int arryLen2=arry2.length;//获取第二个数组长度
		arry1= Arrays.copyOf(arry1,arryLen1+ arryLen2);//把第一个数组扩大
		System.arraycopy(arry2, 0, arry1, arryLen1,arryLen2 );//将两个数组进行合并
		System.out.println(Arrays.toString(arry1));//输出合并后的数组
	}

java合并两个String数组_第1张图片

你可能感兴趣的:(java合并两个String数组)