+ 8
why does not the variable b increase even within the parentheses?
why does not the variable b increase even within the parentheses? and with increment operator before the variable. public class Var { public static void main(String[] args) { int a = 21; int b = 8; System.out.print((a/++b)%3); } } the result is 2
3 Respostas
+ 2
That will print 2 because of operators priority.
First it increments b (so b=9) then it divides a/b (21/9=2) and finally the module (2%3=2).
+ 8
in fact the variable is increased. I was committing on a simple miscalculation. thanks in advanced
+ 1
if you don't want to increment b in first place u
you can use b++ that will increment b only in the next code line