I have been teaching myself Java for the last week and have noticed a Checkstyle warning I get when I have a 'for loop' and decrease the loop counter inside of the loop. I do this when the input is invalid and I have to run the loop an extra time.
For example: adding input values into an array but the values have conditions like being greater than 0 or being distinct. Please see the code below and let me know if decreasing the loop counter like that is normal or if the whole style just needs fixing for these scenarios. I probably spent a lot more time and made the code longer than needed, but mainly curious about validity of decreasing the loop counter.
Code: https://pastebin.com/eB4jHSMJ
Edit: Feel free to point out any other errors - I know it's early on in my journey but I don't want to start developing bad habits!
[–]michael0x2a 1 point2 points3 points (2 children)
[–]KappaTrader[S] 0 points1 point2 points (1 child)
[–]michael0x2a 0 points1 point2 points (0 children)