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