hi,
i have a little problem, it's actually not really a problem, im just curious. i have the following testclass
public class Test{
public static void main(String[] args) {
Double a = false? 1.00: (Double)null; // nullpointer (A)
Double b = false? 1.00: null; // works (B)
}
}
when line (A) is uncommented a NullPointerException is thrown and i have no idea why.
when i comment out line (A), line (B) works. because the type of the conditional operator is of the other if one of them is NullType.
so not really a problem because it's better to use (B) but i still want to know why (A) doesn't work.
Edited by: creichlin on Oct 27, 2008 12:15 PM