什么时候用三元运算符这种简写格式? 当if else运算后,有一个具体的结果时,可以简化写成三元运算符。 否则,如果程序为了输出显示在控制台,那么就用if else 不要简写。例如: int a = 3; if(a>2) { System.out.println(“yes”); } else { System.out.println(“no”); }