J
John Goche
Hello,
I am somewhat curious about the following compile time error:
incompatible types for ?: neither is a subtype of the other
which I am getting in the following situation. Consider:
FooA fooA = new FooA(); // FooA is a subclass of Foo
FooB fooB = new FooB(); // FooB is a subclass of Foo
Foo foo;
foo = fooA == foo() ? fooA : fooB; // foo() returns an instance of Foo
This compiler error goes away when I write the somewhat longer:
FooA fooA = new FooA(); // FooA is a subclass of Foo
FooB fooB = new FooB(); // FooB is a subclass of Foo
Foo foo;
if (fooA == foo()) { // foo() returns an instance of Foo
foo = fooA;
}
else {
foo = fooB;
}
Anyone know the reason for this compiler peculiarity (using J2SE
1.5.0_06).
Thanks,
JG
I am somewhat curious about the following compile time error:
incompatible types for ?: neither is a subtype of the other
which I am getting in the following situation. Consider:
FooA fooA = new FooA(); // FooA is a subclass of Foo
FooB fooB = new FooB(); // FooB is a subclass of Foo
Foo foo;
foo = fooA == foo() ? fooA : fooB; // foo() returns an instance of Foo
This compiler error goes away when I write the somewhat longer:
FooA fooA = new FooA(); // FooA is a subclass of Foo
FooB fooB = new FooB(); // FooB is a subclass of Foo
Foo foo;
if (fooA == foo()) { // foo() returns an instance of Foo
foo = fooA;
}
else {
foo = fooB;
}
Anyone know the reason for this compiler peculiarity (using J2SE
1.5.0_06).
Thanks,
JG