posted 1 month ago
In the practice exercises, in the question 9, the real answer should be 4 5 1, not 4 6 1.. Following the snippet :
int a = 2, b = 4, c = 2;
System.out.println(a > 2 ? --c : b++);
System.out.println(b = (a != c ? a : b++));
System.out.println((a > b) ? (b < c ? b : 2) : 1);
Answer: 4 5 1
Look, in the second line, b its post-increment, not pre increment to be 6, should be 5, but there are no answer for 5. If was this snippet:
int a = 2, b = 4, c = 2;
System.out.println(a > 2 ? --c : b++);
System.out.println(b = (a != c ? a : ++b));
System.out.println((a > b) ? (b < c ? b : 2) : 1);
The answer should be: 4 6 1.
But in the book, b its post increment,so the real answer is 4 5 1,but there's no option for this
Correct?