1. Why does int pop = 0 == 0 ? 1 : null; even compile?

For what it's worth, it doesn't compile for me:

C:\bryan\src\java\pop>java -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

C:\bryan\src\java\pop>type pop.java
class pop
{
    void x()
    {
        int pop = 0 == 0 ? 1 : null;
    }
}

C:\bryan\src\java\pop>javac pop.java
pop.java:5: incompatible types
found   : <nulltype>
required: int
        int pop = 0 == 0 ? 1 : null;
                               ^
1 error

thanks,

bryan

Reply via email to