Question: I have some confusion about generic programming in java:

If Manager is subclass of Employee,

```
Collection<Manager> managers=new Collection<Manager>;  
Collection<Employee> employees=managers;//why illegal?

```

Why the last statement is illegal?

Since according to illustration in the book CORE JAVA,after
the erasion,`Collection<Manager>` and `Collection<Employee>` are
all converted into raw type `Collection`.

Answer: 
This is called [covariance and contravariance](http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29). The issue you just discovered is a traditional problem of type systems. The corresponding [wikipedia page](http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29#Java) discusses this issue in Java. It's worth taking some time to understand these issues correctly has it also relates also to method overriding (since JDK5, you can indeed change the [return type](http://en.wikipedia.org/wiki/Covariant_return_type) of an overriden method as long as it's covariant).
if Y <-- X i.e. X i a type of Y, then you can substitue Y in place of X. However, that's not to say that a list of X is the same as a list of Y. This makes 

```
Collection<Employee> employees=managers; 

```

illegal