import java.time.Instant; public class s1 { private static Double Double; //三元运算法的特点 是个吃亏题... public static void main(String[] args) { int x = 4; //三元运算符 和他比的是 double 因为double 精度大 默认转 double System.out.println(" is " + ((x > 4)? 99.9 : 9) ); System.out.println(" is " + ((x == 4)? 99 : 99.9) ); //三元运算符 和他比的是 int 所以 转int System.out.println(" is " + ((x > 4)? 99 : 9) ); System.out.println(" is " + ((x == 4)? 9 : 99) ); } }
无意中看到 谨记即可.