其他第 2 章示例文件工作正常。我无法弄清楚为什么这个特定的课程会出现这些问题 - 我在评论中标记了错误。
package chapter2;
public class DataTypeConversion {
public static void main(String[] args) {
double x;
int pies = 10; //error: not a statement
x = y; //error: cannot find symbol: variable y
int pies = 10, people = 4;
double piesPerPerson;
piesPerPerson = pies / people;
piesPerPerson = (double) pies / people;
final double INTEREST_RATE = 0.069; //Note that the variable name does not have
amount = balance * 0.069; //error: cannot find symbol: variable: amount
amount = balance * INTEREST_RATE;
}
}
我的目标是将此代码用作独立的 Java 文件,所以我不知道它为什么抱怨这么多。有任何想法吗?