Why can not I print the value of j
in the last statement although the variable j
declared outside the for loop as a local variable?
package practicejava;
public class Query {
public static void main(String[] args) throws java.io.IOException {
int j;
for(int i=1;i<=5;i++) {
j=i;
System.out.println(j);
}
System.out.println("j="+j);
}
}