Java程序性能优化18
使用条件操作符代替"if (cond) a = b; else a = c;" 结构 例子:public class IFAS { void method(boolean isTrue) { if (isTrue) { _value = 0; } else { _value = 1; } } private int _value = 0; } 更正:public class IFAS { void method(boolean isTrue) { _value = (isTrue ? 0 : 1); // compact expression. } private int _value = 0; }