0

I am currently learning loops in java and I have tried the following code:

public class Dummy {
    public static void main(String[] args) {
        for (int c=0, b=150; true; c--, b++) {
            if(c==5){
                System.out.println("c is equal to 5");
                System.out.println("value of b :"+b);
                break;
            }
        }
    }
}

I thought that it would run infinitely as c-- would be infinitely negative and will never be equal to 5 but I ended up getting the following output:

    c is equal to 5
    value of b :145

Can anyone explain why am I getting this output?

0 Answers0