當我編譯下面的代碼,它說:「找不到符號:變速」儘管聲明變量
"error: cannot find symbol: variable max"
但我沒有定義變量max
....
public class Solution {
public static boolean isOneEditDistance(String s, String t) {
if (s.length() >= t.length()) {
StringBuilder a = new StringBuilder (s);
StringBuilder b = new StringBuilder (t);
int max = s.length();
int min = t.length();
}
else {
StringBuilder a = new StringBuilder (t);
StringBuilder b = new StringBuilder (s);
int max = t.length();
int min = s.length();
}
int flag = 0;
if ((max-min)>1)
return flase;
else if ((max-min)==1) {
.....
一般問題的特定情況http://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean – Raedwald
是的,特別是關於「也許變量聲明超出範圍「。 –
如果你使用Math.abs() –