我首先在 Eclipse 中完成所有编程作业,然后将它们放入腻子并提交给我们的老师。在eclipse中,我的一种方法出现了这个奇怪的错误。
它说“令牌上的语法错误,错误的构造。”
public static int factorial(int iVal, boolean DEBUG)
{
int result;
// Defensive programming
if(iVal <= 0)
{
System.out.println("Error: iVal cannot be a negative number!");
System.exit(0);
}
// Calculate result
int factor = iVal;
int counter = iVal - 1;
for(int i = counter; i > 1; i--)
{
if(DEBUG = true)
{
System.out.println("DEBUG");
System.out.println(" Finding the factorial of " + factor);
System.out.println(" Currently working on " + i);
System.out.println(" With an intermediate result of" + iVal);
}
iVal *= i;
}
result = iVal;
// Return result
return result;
} // End of factorial method
它的错误放在由以下组成的行上
System.out.println(" Currently working on " + i);
有任何想法吗?