Can someone explain why this code?
Collection c = (5 == 5) ? new ArrayList() : new HashSet();
produces the following compiler error:
Incompatible conditional operand types ArrayList and HashSet
For reasons that I don’t understand, the following fixes the problem
Collection c = (5 == 5) ? (Collection) new ArrayList() : new HashSet();
I’m using Java 1.4.
This was a bug in 1.4 and has been fixed according bugreport 5080917.