我如何连接char []

时间:2017-04-12 18:21:30

标签: java android

假设我有

Char[] one = {'a','b'};
Char[] two = {'c','d'};

我需要连接它们什么?

一些代码:

Random rand = new Random();

int Plength = 6;
char[] i = new char[Plength];
for (int x = 0; x < Plength; x++){
    i[x] = one[rand.nestIng(one.length)];
}

1 个答案:

答案 0 :(得分:3)

如果要连接两个数组:

productDescription.setLayout(new GridBagLayout());

char[] array1 = ... char[] array2 = ... char[] result = new char[array1.length + array2.length]; System.arraycopy(array1, 0, result, 0, array1.length); System.arraycopy(array2, 0, result, array1.length, array2.length); 包含连接。