0
If a variable is defined within a loop, can it be accessed again in another loop nested within the loop in which it was defined?
If the question sounds confusing, please ask for more clarity. public class Program { public static void main (String [] args) { for (int i = 1; i < condition; i++) { // a bunch of code //second for loop for(int j = 0; j < next condition; j++) { // some more code } // third for loop for (int j = 0; j < another condition; j--) { // some print command } } } }
6 Respuestas
+ 5
The simplest way to understand this is that variables are accessible from outside in but not from inside out 😊.
0
I did try it and I had some difficulty with it. That's why I decided to ask.
0
Thanks D_Stark.