How can I retrieve a for-loop variable outside the loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I retrieve a for-loop variable outside the loop?

Hello together, I've got a simple for loop like this: for(int a=0;value;a++){ } And now I want to select the int a outside the loop like that: System.out.println(a); What do I have to change in my code that it works?

27th Jul 2018, 7:13 AM
erns
1 Answer
0
Do this: int a = 0; for(; a < value; a++){ }
27th Jul 2018, 8:54 AM
Jonas Schröter
Jonas Schröter - avatar