Why is Collection not simply treated as Collection

The reason is quite simple:

You may read Objects from a Collection<?> the same way as from Collection. But you can’t add Objects to a Collection<?> (The compiler forbids this) whereas to a Collection you can.

If after the release of Java 5 the compiler had translated every Collection to Collection<?>, then previously written code would not compile anymore and thus would destroy the backward compatibility.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)