java - Variable repeat error? -
why getting compile-time error in following code?
private static void phi(int n){ if(n > 1000) for(int = 3; <= n; += 2) //do else for(int = 35; <= n; += 90) //do } the error says
java:22: error: variable
idefined in methodphi(int)
but according me, @ scenario, either if statement or else statement executed, never both executed @ same time.
is loophole in java's compilation techniques or method wrong?
edit 2
brackets seem have fixed problem. lot blackbelt.
edit 1
double parenthesis doesn't seem reason still error after removing parenthesis. in fact double parenthesis got added mistake.
there more 1 line after if , before else, have use braces desired behaviour, not necessary in for statement, mandatory in if in case.
also, @joseph82 pointed... there ( in first if!
private static void phi(int n){ if(n > 1000) { for(int = 3; <= n; += 2) //do } else { for(int = 35; <= n; += 90) //do } }
Comments
Post a Comment