Ternary operator
Why the output of following code is 9.0 and not 9 ? If ternary operator is nothing but short form of if-else branch then why java compiler is promoting int to double ? public class Ternary { public static void main(String args[]) { int a = 5; System.out.println("Value is - " + ((a < 5) ? 9.9 : 9)); } } If ternary operator is nothing but short form of if-else branch then why java compiler is promoting int to double ? A conditional expression has a single type, which both the second and third operands are converted to as necessary. The JLS gives the rules determining the expression type, which