Java infering wrong type of a typed HashSet [duplicate]
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: ClassCastException when calling TreeSet<Long>.contains( Long.valueOf( someLongValue ) ) Please see the screenshot for the problem: It seems an entry in the Typed Set cylinderIds is suddenly of type String - but how did that happen? The bean is used from within a JSF page, but I always thought that the type system in Java should prevent this ... Any idea what is going wrong here? Using 1.7.0_06 64 Bit on Windows