I want the following code to count backwards from 33 to 11 but I can’t figure out why this does not work. I’m sure that I’m going to have a Homer Simpson “d’oh” moment when I finally learn the answer, but for now, I’d really appreciate any help.
for(int i = 33; i <= 11; i--)
{
System.out.println(i);
}
The loop will execute only as long as
i <= 11. This is not true the very first time, so the loop never executes. Instead, you want the loop to execute as long asi >= 11— greater than 11, not less than 11. With that small correction, your loop will be fine.