+ 1
Question on a JAVA challenge regarding increment and if-statement
Why is 'b' not changed when 'a' did in the codes below? Also, why is there "" between a+b ? int a = 2, b= 3; if(a++ > b && ++b > 0) { System.out.println(1); } else { System.out.println(a + "" + b); }
2 ответов
+ 3
&& returns only true when both conditions are true.
a++ > b returns false -> the rest is ignored
a + b -> integer
a + " " + b -> string
0
But there is a problem....a was treated like integer and b is treated like string....... That cant be posible because a++ raise and ++b didn it