I am working on the “Powers of” generator and I get an error that variable i cannot be found. I clearly declared it in the for loop
public class EP63
{
private static int answer;
public static int PowerGenerator(double aFactor)
{
for(int i = 1; i < 12; i++);
{
answer = Math.pow(aFactor,i);
nextPower();
return answer;
}
}
public static double nextPower()
{
System.out.println(answer);
}
}
Can someone explain to me how to fix this problem?
It’s this line:
Change to:
The body of the for loop is a single expression.
;is interpreted as an no-op expression, so the{ }block is not part of the loop, thereforeiis not defined there.