Why am I getting a compile-time error in the following code?
private static void phi(int n){
if(n > 1000)
for(int i = 3; i <= n; i += 2)
//do something
else
for(int i = 35; i <= n; i += 90)
//do something
}
The error says
java:22: error: variable
iis already defined in methodphi(int)
But according to me, at any scenario, either if statement or else statement will be executed, but never both will be executed at the same time.
Is this a loophole in Java's compilation techniques or is my method wrong?
EDIT 2
Brackets seem to have fixed the problem. Thanks a lot blackbelt.
EDIT 1
Double parenthesis doesn't seem to be a reason as I still get an error after removing the parenthesis. In fact the double parenthesis got added by mistake.