所以我的代碼試圖找到一個字符串是否類似於另一個目標字符串(目標已定義)。它根據兩個字符串中有多少個字母相似來得分。然而,在我的for循環中,我得到了用於定義tChar的m的Can not Find Symbol錯誤,但它被用來定義iChar ...我很困惑。有一個更好的方法嗎?錯誤:無法找到循環的符號
public int score(String input){
int score;
char iChar, tChar;
for (int m=0;m<input.length();++m)
iChar = input.charAt(m);
tChar = target.charAt(m);
if (iChar == tChar)
score = score + 1;
else
score = score;
return score;
}
我沒想到那個......謝謝! –