What will be the result of compiling and running the following code?

1. public static void main(String[] args) {
2.     for (int i = 0; i <= 10 ; i++) {
3.         if (i > 6) break;
4.     }
5.     System.out.println(i);
6. }
Explanation
Variable 'i' exists only within the cycle.
In line 5 the 'i' variable is out of the visibility scope.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback