合并数组
import java.util.Arrays; import org.junit.Test; public class Xmltest { @Test public void xxx(){ String[] left = {"0","1"}; String[] right = {"2","3"}; int ll = left.length; int rl = right.length; left = Arrays.copyOf(left, ll + rl); System.out.println(Arrays.asList(left)); System.arraycopy(right, 0, left, rl , ll); System.out.println(Arrays.asList(left)); } }
结果:
[0, 1, null, null] [0, 1, 2, 3]