0
在我的以下代码中,我将字符串数组转换为字符数组来改变字符。将字符串数组转换为字符串数组
char[][] currentGuessArray = new char[currentGuessPhrase.length][];
for (int x = 0; x < currentGuessPhrase.length; x++) {
currentGuessArray[x] = currentGuessPhrase[x].toCharArray();
}
for (int x = 0; x < correctPhrase.length; x++) {
for (int a = 0; a < correctPhrase[x].length(); x++) {
if (correctPhrase[x].charAt(a) == guess) {
currentGuessArray[x][a] = guess;
}
}
我试过如下:
for (int x = 0; x < currentGuessArray[x].length; x++){
currentGuessPhrase[x] = currentGuessArray[x].toString();
}
但它似乎没有改变的代码。
的字符串数组包含随机单词,如: “火”, “金婚”, “非法的”,等等。
编辑:下面是一个例子运行:
miracles
horrible
illegal
horrible
good
这些都是字符串存储在currentPhrase[]
输入: 一个
预期输出:
___a____ ________ _____a_ ________ ____
实际输出:
[[email protected] [[email protected] [[email protected] [[email protected] ____
你为什么要使用currentGuessArray二维数组简单地改变?你有错误吗?显示您的预期和实际结果。 – Sionnach733