This question already has answers here: Returning null as an int permitted with ternary operator but not if statement (8个答案) 5年前关闭。 如果我编译并运行以下类(使用Java SE 7,则可以), class Foo { public static void main(String[] args) { System.out.println(true ? null : 42); // Syst…