【发布时间】:2014-04-27 10:49:21
【问题描述】:
在编译我的新 Android 应用程序 Android Studio 退出时出现此错误: “找不到符号变量 percscon”。
我的代码是
if(ulterioretext.equals("")) {
....
} else {
String uno = (String) "1";
float numbersconto = Float.valueOf(ulterioretext);
if(numbersconto <= 9){
String percscont = (String) uno + ".0" + ulterioretext;
} else {
String percscont = (String) uno + "." + ulterioretext;
}
float percscontfloat = Float.valueOf(percscont); <- The error is here
....
}
如果我把 "String percscont = (String) uno + ".0" + ulterioretext;"在 if 之外一切正常,但如果它在“if”之内,编译器没有找到 percscont 变量。为什么?
谢谢
【问题讨论】:
-
从您刚刚展示的代码中看不太容易,但我认为您在 if 的第一个分支中使用了 percscont 变量。能否请您发布整个 if 代码?
标签: android variables sdk android-studio