0

Iterate till 9 and repeat again or get 1st value again.

Something like 1,2,3,4,5,6,7,8,9,1 or 1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,...... I used for(i=1; i<=9; i++) { if(i<=9) { return i=1; }}

1st Aug 2019, 1:35 AM
Prithvi
2 Answers
+ 3
I’m not sure I entirely understand, you want to continously loop through 1-9? you can do this- however there is no break-out and the continuation condition will always be true, so it will run infinitely: int i = 0; while(true) { i++; System.out.println(i); if(i == 9) { i = 0; } }
1st Aug 2019, 3:01 AM
Jake
Jake - avatar
0
Thankyou! Jake. I will try this code.
1st Aug 2019, 2:29 PM
Prithvi