Given the code fragment:
int x = 100;
int a = x++;
int b = ++x;
int c = x++;
int d = (a < b) ? (a < c) ? a : (b < c) ? b : c;
System.out.println(d);
What is the result?
A.
100
B.
101
C.
102
D.
103
E. Compilation fails
题解
声明 d 变量的那行会编译错误,原因在于「?:」条件三元操作符的使用方式是错误的。条件三元操作符的「?」和「:」必须是成对出现,有几个「?」就有几个「:」。
