What will be printed as a result of the following code execution?

public class Main {
    public static void main(String args[]) {
        byte b = 0;
        while (++b > 0);
        System.out.println(b);
    }
}
Explanation
Variables of byte type store values in the range -128 .. 127. When the value of a b variable reaches the maximum value allowed for this type (127) in the loop, the following increment (++) will reset it to a minimum allowed value (-128). It will start the countdown all over again.

Thanks a lot, @paulch1991 :) We will try do best we can

2016 Mar 1, 9:40:35 PM

Must be agAin! I think so) Good luck in your hard work!)

2016 Feb 20, 11:20:21 AM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback