Getting unwanted NullPointerException in ternary operator - Why? [duplicate]
问题 This question already has answers here : Short form for Java If statement returns NullPointerException when one of the returned objects is null [duplicate] (3 answers) Closed last year . While executing the following code, I am getting a NullPointerException at line: value = condition ? getDouble() : 1.0; In earlier lines when I use null instead of getDouble() everything works and this is strange. public class Test { static Double getDouble() { return null; } public static void main(String[]